<?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 komangsughosa on Medium]]></title>
        <description><![CDATA[Stories by komangsughosa on Medium]]></description>
        <link>https://medium.com/@0xdc9?source=rss-565e691f7752------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*o-0xQY74_12-6_GA</url>
            <title>Stories by komangsughosa on Medium</title>
            <link>https://medium.com/@0xdc9?source=rss-565e691f7752------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:33:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0xdc9/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[Kernel exploitation: The Struct Cred]]></title>
            <link>https://medium.com/@0xdc9/kernel-exploitation-the-struct-cred-fa9d56d890bb?source=rss-565e691f7752------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa9d56d890bb</guid>
            <category><![CDATA[binary-exploitation]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[komangsughosa]]></dc:creator>
            <pubDate>Fri, 23 Dec 2022 18:38:26 GMT</pubDate>
            <atom:updated>2023-01-29T10:04:49.564Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1. Introduction</strong></p><p>When solving a CTF task especially kernel exploitation, most of the time the enabled security features are SMAP, SMEP, KPTI, KASLR. Now, what if there’s another security enabled such as CONFIG_FGKASLR=y , CONFIG_STATIC_USERMODEHELPER , and # CONFIG_KALLSYMS_ALL is not set pretty sure we are facing a dead end right? nope, not at all</p><p><strong>2. The Configuration</strong></p><p>In November 2022 a CTF event called National Cyber Week 2022 CTF, I Created a challenge named Invoke which has a kernel configuration compiled with</p><pre>CONFIG_SLAB=y<br># CONFIG_SLUB is not set<br>CONFIG_FG_KASLR=y<br>CONFIG_STATIC_USERMODEHELPER=y</pre><p>what’s important in this configuration is FG_KASLR enabled and CONFIG_STATIC_USERMODEHELPER which we can shortly conclude that we cannot change the value of modprobe path because of the CONFIG_STATIC_USERMODEHELPERand also we getting address of commit_creds and prepare_kernel_cred are impossible because of the enabled FG_KASLR. With FG_KASLR enabled, every time kernel boot up some kernel function including commit_creds and prepare_kernel_cred will be randomized but the randomization is not predictable nor cannot be calculated using offset like normal KASLR.</p><p><strong>3. The cmdline and The module</strong></p><p>let’s take a look at the launch.sh and the kernel module</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0iPKlJLgfKoRD96bGUKOfQ.png" /></figure><p>we can see that it has KPTI, FGKASLR, and SMEP are enabled but interestingly the SMAP is disabled which we can write or read data from kernel to userland? kinda. let’s disassemble the module</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LLZnOfNxGwb1jzxgbH85aA.png" /><figcaption>invoke_ioctl</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7l0PSjB9LrjqEEyKjQa67Q.png" /><figcaption>invoke_read</figcaption></figure><p>There are two main function that we will hands on, the first ioctl argument 0x1771 will set the current pointer from the userland ioctl provided value where if we take a look at the invoke_read the pointer will return it’s current value which means we have an <strong>Arbitrary read</strong>. The second ioctl argument 0x1772 will write from the userland ioctl provided value to current pointer set which now we can see that we have <strong>Arbitrary read and write</strong>. But, how can we exploit the kernel module to either get the /flag or get gain root? apparently the invoke_read will return a kmalloc pointer which then we can iterate with with ioctl for arbitrary read.</p><p><strong>4. The struct cred</strong></p><p>When a userland program runs, the kernel has it’s own address for the current running user program (current_task). when a current task address of a running program is leaked, we can perform arbitrary write to struct cred . the struct cred holds value as listed in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GW0qE2viHCZIiw9GvCz7UA.png" /><figcaption>struct cred</figcaption></figure><p>So what’s the exploitation plan? we set our program name with prctl to AAAAAAAAthen perform arbitrary read using the leak from the invoke_read to find a memory in the kernel that contains 0x4141414141414141</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*eqLkHOB2k0Tt3N1uykd4jA.png" /><figcaption>recon.c</figcaption></figure><p>compile it using with gcc -static recon.c -o reconand run it</p><p><strong>5. The analysis and the pwning</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNGOkWqUn3OF-0OKqCHXHA.png" /><figcaption>recon result</figcaption></figure><p>from the result the address that contains 0x4141414141414141 has been found, attach it to the gdb and substract the current address of 41 with 0x10</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*uA_Xf0rem3p9wGKlIN06gg.png" /></figure><p>before the address that contains 41, there is an address that contains an address too but if we take a look at it, the address contains 0x3e8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*TpjD4GPPaDnN9GWYuHPAeg.png" /></figure><p>specifically, the value of 0x3e8 is 1000 which is the current user id that is running the program. Theoretically, we have found the struct cred address. With arbitrary write available, if the address that contains 0x3e8 we write it with 0 we will become root! so here’s the final exploit plan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*l1Xtg8yUdZPSe2Sj4bRdFQ.png" /><figcaption>exploit plan</figcaption></figure><p>here’s the PoC and the exploit result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*e72ktDzlTXsL-2oKo2upew.png" /><figcaption>exploit.c</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BkjZGQ7-YuaC6Kl81oa1wQ.png" /></figure><p>from here we learned that with arbitrary read and write we can find our struct cred of our current program running then write it with 0 to gain root</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa9d56d890bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AraCTF2022 Directive Communication write up(kernel exploitation)]]></title>
            <link>https://medium.com/@0xdc9/aractf2022-directive-communication-write-up-kernel-exploitation-9b1aff6077b4?source=rss-565e691f7752------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b1aff6077b4</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[binary-exploitation]]></category>
            <category><![CDATA[pwn]]></category>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[kernel]]></category>
            <dc:creator><![CDATA[komangsughosa]]></dc:creator>
            <pubDate>Wed, 25 May 2022 23:30:22 GMT</pubDate>
            <atom:updated>2022-06-19T08:46:51.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*NafBzflI6bx-mH-pPUsbWw.png" /></figure><p><strong>Bagian Pertama: Analisa</strong></p><p>Pada soal ini partisipan diberikan sebuah file berupa zip, IP address, dan port untuk melakukan koneksi ke instansi soal. Mari kita lihat didalam file zip terlebih dahulu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xdVVUz96zLg0lOGWxSfnAw.png" /></figure><p>Karena soal ini merupakan kernel exploitation atau eksploitasi kernel, hal utama yang harus dilakukan adalah mengekstrak isi dari initramfs.cpio.gz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYlQcVOCaCWgoNPfHBzjrw.png" /></figure><p>Dari sini kita mendapatkan Kernel Object yang bernama panas.ko dimana kernel object tersebut akan di masukan kedalam sistem ketika dijalankan. Mari kita Decompile dengan Cutter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nO34tAdpDKgkJiRsu1ZLSQ.png" /><figcaption>lokasi kernel object driver berada di /proc/panas</figcaption></figure><p>Dari sini kita mengetahui bahwa Kernel menggunakan proc_entry dimana lokasi kernel driver berada di /proc/panas</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TaLee8vP0kkd9nlPqg81MQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TaLee8vP0kkd9nlPqg81MQ.png" /><figcaption>device_ioctl</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84ub6LKsmZIVY1Jpe9nnbg.png" /><figcaption>device_ioctl.cold.2</figcaption></figure><p>Disini kita mendapatkan beberapa informasi yaitu untuk berkomunikasi dengan kernel kita harus menggunakan ioctl dan 2 parameter ioctl yaitu 0x1777 dan 0x1778 . Dari hasil decompilation, parameter 0x1777 digunakan untuk mengisi alamat blank dimana jika kita gunakan parameter 0x1778 maka alamat yang ada di blank akan di jalankan seperti function() pada normalnya. Sekarang mari kita lihat keamanan yang ada pada kernel object dengan checksecdan isi dari launch.sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrZeEZMo0_XGjzacKL8lxQ.png" /><figcaption>hasil checksec</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMHO2gqaq6UMUBPRacYIYg.png" /><figcaption>isi dari launch.sh</figcaption></figure><p>Dari sini ada beberapa hal yang harus diperhatikan. Ketika launch.sh dijalankan, setiap alamat fungsi didalam kernel seperti commit_creds tidak akan diacak karena adanya nokaslr dan teknik eksploitasi dengan <strong>ret2usr</strong> bisa dilakukan karena smap , smep , dan kpti bersifat non-aktif. Pada dasarnya, ret2usr adalah suatu teknik exploitasi dimana fungsi program di userland dieksekusi dikernel-land sehingga eskalasi hak atau “privilege escalation” bisa terjadi.</p><p>Ketika launch.sh dijalankan, kita bisa melihat alamat ataupun alamat fungsi kernel di /proc/kallsymstapi akan 000000000000 yang bisa dibilang, belum terlihat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vOWyZ_3oUz1kH5BKChZHCA.png" /></figure><p>Hal yang perlu dilakukan agar bisa mendapatkan alamat asli fungsi didalam kernel adalah dengan mengedit init pada line akhir dan membuat initramfs.cpio.gz dengan init terbaru yang akan kita ubah</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DVOT1RVxK-oXn3NVU6bmdg.png" /><figcaption>ubah init</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgD25AS3G-fXF_EEuAlBNA.png" /></figure><p>Setelah init di ubah, launch.sh juga perlu di ubah pada bagian -initrd untuk menjalankan NEW-initramfs.cpio.gz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kkkRN-modRrszL3POh5M4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PjFB66eay-KPkfInKva8A.png" /></figure><p>Alhasil kita berhasil mendapatkan beberapa alamat untuk mempersiapkan suatu exploit.</p><p><strong>Bagian Kedua: Exploitasi di instansi lokal</strong></p><p>Karena kita sudah melakukan analisis dan modifikasi pada bagian sebelumnya, berikut merupakan program untuk memicu bug pada kernel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJkX6ehBH3uVn2GDzRu2OA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QG3AZOdrDvvZ8zzYDWeSUA.png" /></figure><p>Dan RIP(register instruction pointer) mengarah dan mengeksekusi 0x41414141414141414141</p><p><strong>Exploit 1: Classic commit_creds(prepare_kernel_cred(0)</strong></p><p>Hal utama yang diperlukan untuk melakukan ret2user untuk mengeksekusi fungsi commit_creds(prepare_kernel_cred(0)) adalah alamat dari commit_creds dan prepare_kernel_cred . Berikut dibawah adalah exploitnya beserta penjelasannya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJjJwFoYwiouBVgYAgxKEg.png" /></figure><p>dan jika kita jalankan di lokal instansi, harusnya kita mendapatkan user sebagai root</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*veiVEkfBSrXFALQO_YFkAA.png" /><figcaption>compiling exploit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zp3oBKRT01XrLXESdqdxAg.png" /></figure><p><strong>Bagian Ketiga: Exploitasi di remote</strong></p><p>Di instansi lokal, exploit kita berjalan dengan sukses. Untuk mengirim exploit ini kedalam instansi remote, kita perlu membuat sebuah program menggunakan bahasa pemrograman python dengan module atau library bernama pwntools, time, dan os. Berikut merupakan program python-nya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2PUsQe3JCWwoSrw1J43GQ.png" /></figure><p>Mari kita jalankan program python-nya</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FZrFbeiCM0AAi0Wgt8DTNQ.png" /></figure><p>setelah mendapatkan interaktif, kita hanya perlu menjalankan exploitnya dengan ./exploit dan alhasil</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spYOhKgaRd51gf1zRRQ-pw.gif" /></figure><p>kita berhasil melakukan eskalasi hak atau “privilege escalation” ke root dan isi dari /flag bisa kita lihat</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b1aff6077b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Cache Untuk OSINT]]></title>
            <link>https://medium.com/@0xdc9/google-cache-untuk-osint-319e29f4b125?source=rss-565e691f7752------2</link>
            <guid isPermaLink="false">https://medium.com/p/319e29f4b125</guid>
            <category><![CDATA[investigation]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[osint]]></category>
            <dc:creator><![CDATA[komangsughosa]]></dc:creator>
            <pubDate>Fri, 24 Sep 2021 08:50:44 GMT</pubDate>
            <atom:updated>2021-09-24T08:50:44.139Z</atom:updated>
            <content:encoded><![CDATA[<p>Google Cache Untuk OSINT</p><p>Pernahkah kalian mengakses suatu situs namun situs tersebut tidak menampilkan tampilan yang kita inginkan atau butuh waktu lama untuk menampilkan tampilan situs tersebut? sebagai contoh kamu ingin membaca berita yang terjadi semalam pada pagi ini, tapi situs berita favorit kamu butuh waktu lama untuk melakukan load tampilannya atau ketika kamu sedang melakukan OSINT dengan metode Google Dorking, website yang kamu ingin akses ternyata memberikan response 404 atau tidak bisa diakses. Apa yang harus kamu lakukan? jawabannya adalah menggunakan Website Cache, seperti Google Cache, Wayback Machine, atau Archive.is. pada artikel ini, saya akan menjelaskan apa itu Google Cache dan cara kerjanya.</p><p>Secara singkat, Google Cache merupakan snapshot dari tiap web page yang digunakan untuk backup jika suatu ketika page tersebut tidak bisa diakses (link :<a href="https://support.google.com/websearch/answer/1687222?hl=en">https://support.google.com/websearch/answer/1687222?hl=en</a> ), bagaimana cara kerja Google Cache? kita akan menggunakan 1 contoh skenario dimana seseorang sedang melakukan information gathering melalui OSINT dengan google dorking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Husnt5baN-0NZ54qevnyUA.png" /><figcaption>hasil google search dengan metode dorking</figcaption></figure><p>Dari hasil pencarian dorking google, kita dapat melihat adanya website yang sebelumnya telah dideface oleh MC’Sl0vv.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdFRsChkscGUQLiknTmwNA.png" /><figcaption>mengakses situs yang harusnya memberikan info teretas oleh MC’Sl0vv</figcaption></figure><p>Namun ketika kita mengakses website tersebut, tidak terlihat adanya tanda-tanda bahwa website tersebut telah dideface. bahkan ketika kita mengecek source code dari website tersebut tidak adanya tanda-tanda dari MC’Sl0vv pada website tersebut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cwyNOaxF-_aKvT4xQFgvjA.png" /><figcaption>mencari aktor peretas(MC’Sl0vv)</figcaption></figure><p>Pada titik ini hal yang perlu dilakukan adalah mengecek google webcache dari website tersebut dengan cara melihat view-source dari hasil pencarian google dan mencari url yang sudah tercampur oleh webcache.googleusercontent.com .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1KDk-NLCHzMLboWXKt1j9w.png" /><figcaption>mencari url webcache</figcaption></figure><p>Setelah mendapatkan url dari google webcache dari website tersebut, kita perlu melakukan decode url google webcache dengan unescape unicode character. gambar di bawah ini menjelaskan bagaimana menyalin url dan melakukan proses decoding terhadap url google webcache tersebut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grvTWsGmKZwD5eoW8j9wPg.png" /><figcaption>menyalin url webcache</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjj-wqN2JGs3QShWqAzZzA.png" /><figcaption>melakukan decoding webcache url</figcaption></figure><p>Setelah melakukan decode dan menghilangkan backslash pada url yang ditemukan pada langkah sebelumnya, kita dapat mengakses url tersebut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IkiKyelxw-3kC29nmmUXzg.png" /><figcaption>mengakses url webcache yang telah di decode</figcaption></figure><p>Gambar diatas adalah tampilan ketika kita mengakses webpage cached dari website tersebut, dan dari sini dapat dipastikan bahwa website tersebut pernah dideface oleh aktor MC’Sl0vv</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=319e29f4b125" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>