<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Panagiotis Nakoutis on Medium]]></title>
        <description><![CDATA[Stories by Panagiotis Nakoutis on Medium]]></description>
        <link>https://medium.com/@pnakouti?source=rss-dc968254ead4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Panagiotis Nakoutis on Medium</title>
            <link>https://medium.com/@pnakouti?source=rss-dc968254ead4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:09:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pnakouti/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CTFlearn writeup: RE_verseDIS challenge using Ghidra.]]></title>
            <link>https://medium.com/@pnakouti/ctflearn-writeup-re-versedis-challenge-using-ghidra-81f3a4907e04?source=rss-dc968254ead4------2</link>
            <guid isPermaLink="false">https://medium.com/p/81f3a4907e04</guid>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ghidra]]></category>
            <dc:creator><![CDATA[Panagiotis Nakoutis]]></dc:creator>
            <pubDate>Thu, 06 Oct 2022 08:40:55 GMT</pubDate>
            <atom:updated>2022-10-06T08:40:55.001Z</atom:updated>
            <content:encoded><![CDATA[<p>RE_verseDIS is a simple challenge for those of you who are new to reverse engineering. In the next scroll-downs you’ll find a step by step guide on how to analyze a simple ELF executable file.</p><p>link to the challenge: <a href="https://ctflearn.com/challenge/188">https://ctflearn.com/challenge/188</a></p><p>In the beginning of each analysis you will first have to do some file identification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*mD68oiHb7k5YUE36M9CADw.png" /><figcaption>Picture 1 — File identification.</figcaption></figure><p>File -s makes some tests (filesystem tests, magic tests, and language tests) for file identification process, which is crucial when analyzing malware. Here, file -s shows that we are dealing with an ELF 64-bit executable.</p><p>For the next step, we’ll make a strings check and mark the interesting ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*ctLmFCoiAdJD5sRPLTZsIg.png" /><figcaption>Picture 2 — Strings of ELF executable.</figcaption></figure><p>The executable prompts the user to input a password which is hardcoded inside the file and afterwards prints the success or the failure. Pretty simple and familiar right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*lWwjg6Hn6K9urnqSPwjcTg.gif" /><figcaption>Picture 3 — Running the executable</figcaption></figure><p>Going straight to the disassembler. For this analysis I am going to use <a href="https://ghidra-sre.org/">Ghidra</a> both for disassembling and debugging the file. Ghidra’s decompiler automatically shows the source code for you to get a grasp on what are the assembly instructions you are watching on the other tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufJ_BtPU6c_s22gw9Ua6pg.png" /><figcaption>Picture 4 — Ghidra disassembler (left tab) and decompiler (right tab)</figcaption></figure><p>The main function starts at address 0x00100740 and as we can see it handles the strings we noticed in the beginning of the examination.</p><h3>SOLUTION #1 — Disassembler only</h3><p>Let’s take a closer look at the decompiler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*cOmBJezVlRZQc5BVzTLVHQ.png" /><figcaption>Picture 5 — Ghidra decompiler</figcaption></figure><p>There are some things to notice. We have two integers local_10 and local_c. User input comes next via scanf and after that a XOR operation takes place. Obviously the hardcoded password is XORed and after that it’s being compared to the input.</p><p>Let’s take a look at where the “key” points in memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*oIvWa-hyXKcf1DWbv4uGJw.png" /><figcaption>Picture 6 — Key pointer</figcaption></figure><p>“key” is used in the XOR operation along with the “str” for storing the unencrypted data in “msg” variable. Password length should be less than 0x16 bytes according to the loops.</p><p>Let’s move on to the “str” pointer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMFAtlzg_KhFkP5nYgxYsg.png" /><figcaption>Picture 6 — Str pointer</figcaption></figure><p>It looks like there’s a pattern of 4 bytes (dword) in “str”. Using this as the data and the “key” as the key in a XOR operation we can get the flag.</p><p>data = 08 06 2c 3a 32 30 1c 5c 01 32 1a 12 45 1d 20 30 0d 1b 03 7c 13<br>key = IdontKnowWhatsGoingOn<br>msg = XOR (data, key) = <strong>AbCTF{r3vers1ng_dud3}</strong></p><h3>SOLUTION #2 — Debugging the file</h3><p>If you don’t want to mess with the code and decryption, you can let the executable do its magic for you. You just have to stop it the right time and sniff the right data out of the registers or its memory.</p><p>First, we have to open the file with the Ghidra debugger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*Ps_uxQXyA9SMZRHQR4c5cQ.png" /><figcaption>Picture 7 — Open with debugger</figcaption></figure><p>At the top of the window, click on the “Debug problem in GDB locally IN-VM”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*NAOnYD5onIe0AKiFjfwJnw.png" /><figcaption>Picture 8 — Debug option</figcaption></figure><p>Ghidra’s known issue for not transferring target IO into other console makes things a bit difficult since we need user input for the program to run. However, we can use gdb’s set inferior-tty command to transfer the IO to our terminal and then start debugging.</p><p>First we need to check our terminal tty</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*ksHIFabsz7wb7exT7U_Aog.png" /><figcaption>Picture 9 — Terminal tty</figcaption></figure><p>and after that, send it to bed, waiting for the output of gdb.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*aqTLak2mayOp6MwErD0SAw.png" /><figcaption>Picture 10 — Terminal zzzzz</figcaption></figure><p>On Ghidra Interpreter tab type <strong>set inferior-tty /dev/pts/2</strong> and press enter. Now we can have GDB’s IO into our terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*QlrKjcF9YOUs2gcqf9qZ5Q.png" /><figcaption>Picture 11 — Ghidra Interpreter (back) and GDB’s output on the terminal (front)</figcaption></figure><p>What we will try to find next is the value of “msg”. The source code (Picture 5) dictates that msg is being created in the first loop where all ASCII bytes are being decrypted one by one. We can either <br><strong>1)</strong> sniff the data there or <br><strong>2)</strong> find the point in memory where the value is stored afterwards. <br>For the first option, the instruction at offset 0x00100818 does the job:<br><em>MOVZX EAX=&gt;msg, byte ptr [RDX + RAX*0x1]</em></p><p>If we set a breakpoint there and continue with program execution and a step-into we can get the following output in R/EAX register:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xq9lleG9wzLdqxIYk5giRA.gif" /><figcaption>Picture 12 — Breakpoint at offset 0x00100818 and execution.</figcaption></figure><p>R/EAX data actually represent the ASCII bytes of the flag.</p><p>For the second option, we can make use of the instruction at offset 0x00100811:<br><em>LEA RAX,[555555601140]</em></p><p>By setting a breakpoint there and continue with program execution and a step-into we can get the following data on address 555555601140:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_83HpZanEmMY5-h1cqYvyA.gif" /><figcaption>Picture 13 — Breakpoint at offset 0x00100811 and execution</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*jx5QcqPFO_cdrlgDazoPqw.png" /><figcaption>Picture 14 — Data at offset 0x<em>555555601140</em></figcaption></figure><p>Congratulations for finding your 21byte flag!</p><p>You can also find me on twitter: <a href="https://twitter.com/4n6equals10">4n6equals10</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81f3a4907e04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A deep dive into Ubuntu thumbnails.]]></title>
            <link>https://medium.com/@pnakouti/dear-reader-3a74ed9d0b94?source=rss-dc968254ead4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a74ed9d0b94</guid>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[dfir]]></category>
            <category><![CDATA[forensics]]></category>
            <dc:creator><![CDATA[Panagiotis Nakoutis]]></dc:creator>
            <pubDate>Wed, 06 Jul 2022 16:04:41 GMT</pubDate>
            <atom:updated>2022-07-06T16:13:54.146Z</atom:updated>
            <content:encoded><![CDATA[<p>Dear reader,</p><p>this is a demonstration of what I’ve found out during an investigation, trying to explain the presence of some cached photos lying in the /home/.cache folder in an Ubuntu system.</p><p>Everybody in the DFIR community has come across thumbnails in various examinations. However, the real struggle is trying to understand the forensic value of the thumbnail pictures. Below, you will find the results of various tests I have created just for you dear friend, to shed some more light in your examination of Linux systems with GNOME desktop environment.</p><p>There are two directories in which thumbnails are stored in an Ubuntu distro.</p><p>1. <strong>/home/.cache/thumbnails/large</strong></p><p>2.<strong> /home/.cache/thumbnails/normal</strong></p><p>The first one stores thumbnails with dimensions up to 256×256 and the second up to 128×128. Non squared thumbnails are scaled so their large dimension is at most 256 or 128. But that’s not the difference you were seeking by reading this article right?</p><p>Let’s take a closer look at what’s happening when a new picture is created in an UBUNTU distro. For my demonstration I used an Ubuntu 20.04.4.</p><p>By default, thumbnails in UBUNTU distros are handled by <a href="https://gitlab.gnome.org/GNOME/gnome-desktop/blob/master/libgnome-desktop/gnome-desktop-thumbnail.c">Gnome-Thumbnail-Factory</a>. Every time a new pictured is created on an Operating System, some caching mechanism has to take place, in order to save your processing resources from overloading each time you want, for example, to navigate to a directory full of pictures with thumbnail view. For this reason, Gnome-Thumbnail-Factory creates thumbnails of pictures and stores them in /home/.cache/thumbnails /large.</p><p><strong>So when does Gnome-Thumbnail-Factory saves that picture on this directory?</strong></p><p>When you navigate to the originating pictures’ directory with thumbnail view, every picture is being processed by Gnome Thumbnail Factory and a thumbnail is being created. Let’s take a look (Picture 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*wIBvlTVbYP1ahMbySj0wiw.gif" /><figcaption>Picture 1 — Creating picture, toggling view and eventually thumbnail creation</figcaption></figure><p>As you can see, a new thumbnailed .png picture is created and named after a hash-like value. Let’s look at the hex/strings of the file (Picture 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*1JwCAJ2TeTZv2LSv2oMxgA.png" /><figcaption>Picture 2 — Hexdump of created thumbnail (<strong>/home/.cache/thumbnails/large</strong>)</figcaption></figure><p>PNG files actually store metadata in chunks as described <a href="https://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_PNG_files">here</a>. In our example, we can see 3 chunks:</p><ol><li><strong>tEXtThumb::URI → file:///home/uuubnt/Pictures/Screenshot%20from%202022–06–30%2019–23–15.png</strong></li><li><strong>tEXtThumb::MTime → 1656606222</strong></li><li><strong>TEXtSoftware → GNOME::ThumbnailFactory</strong></li></ol><p>The 1st metadata chunk is the URI of the originating file. When we calculate the md5 hash of that URI, we will actually get the name of the thumbnail.</p><p>md5(“file:///home/uuubnt/Pictures/Screenshot%20from%202022–06–30%2019–23–15.png”)= <strong>17cae85caef4f2b32f1b9272564a672d</strong></p><p>The 2nd metadata chunk (tEXtThumb::MTime) is the modification time, in Unix Epoch, of the originating file and NOT the time the thumbnail was created. 1656606222 represents 2022–06–30 16:23:42 UTC. (My test machine is set to UTC +3)</p><p>The 3rd metadata chunk is always Gnome Thumbnail Factory</p><p>The filesystem timestamps on this file (mtime, atime) indicate the time that <strong>the user navigated to the originating file’s directory with thumbnail view enabled</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*BNrepfOWUib8AQ5X88h1yA.png" /><figcaption>Picture 3 — Filesystem timestamps indicate the moment of navigation to the folder of originating file</figcaption></figure><p>For more information on Linux filesystem timestamps check out <a href="https://www.howtogeek.com/517098/linux-file-timestamps-explained-atime-mtime-and-ctime/">this article</a>.</p><p>By this time, I have only taken a screenshot on my system and switched to thumbnail view in its directory.</p><p>Now let’s double click on the original picture I have created and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*-h7asuv4QDOEBhAy9JSrDw.gif" /><figcaption>Picture 4 — Opening picture file and eventually another thumbnail creation</figcaption></figure><p>When we open the original file, another thumbnail is created, but this time in the /home/.cache/thumbnails/<strong>normal </strong>directory. This thumbnail is also named after the md5 hash of the originating file’s absolute path. Let’s take a look at this file’s hex/string data (Picture 5).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*iKdmG_hgnJTj0eei8Dy8NA.png" /><figcaption>Picture 5 — Hexdump of created thumbnail (<strong>/home/.cache/thumbnails/normal</strong>)</figcaption></figure><p>Again, the same metadata chunks can be found. However, the filesystem timestamps of this file (mtime and atime) indicate the timestamp that this picture was <strong>opened for the first time</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*F9TgF6kIJpROrcWM4A71-g.png" /><figcaption>Picture 6 — Filesystem timestamps indicate the moment the original file opened</figcaption></figure><p>The same caching takes place if the originating file’s directory is hidden or the originating file lies in an encrypted container as well.</p><p>Opening a picture file via terminal (e.g. xdg-open $file) will also trigger a thumbnail creation in the <strong>/home/.cache/thumbnails/normal</strong> directory, as long there interference from the OS’s file manager (Nautilus for this distro). Opening the file with another application (e.g. Firefox, Nomacs) does not trigger thumbnail creation in the above directory.</p><p>Behavioral similarities can be found amongst many Linux distros regarding the thumbnail creation. Some source codes can be found below:</p><p><a href="https://github.com/mate-desktop/mate-desktop/blob/master/libmate-desktop/mate-desktop-thumbnail.c">Mate-thumbnailer</a></p><p><a href="https://invent.kde.org/network/kio-extras/-/blob/master/thumbnail/thumbnail.cpp">KDE-thumbnailer</a></p><p><a href="https://developer.gimp.org/api/2.0/libgimpthumb/GimpThumbnail.html">GIMP-thumbnailer</a></p><p>Thumbs up for Jens Finke and Olivier Sessink for their work here:</p><p><a href="https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#CREATION">https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html</a></p><p>To sum up, Linux distros with Gnome desktop environment store thumbnails that contain metadata of great forensic value. Their internal metadata can lead to the original file and their filesystem metadata show the interactions that the user had with the original picture file.</p><p>I hope you liked this post and hopefully you found something useful for your next examination or project. Feel free to share this post with any other DFIR fellow that might find it useful. Thank you!</p><p>Twitter: @4n6equals10</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a74ed9d0b94" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>