<?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 Cafe Babe on Medium]]></title>
        <description><![CDATA[Stories by Cafe Babe on Medium]]></description>
        <link>https://medium.com/@0xd0cf11e?source=rss-137f3b654279------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yxFa7BJQ4JoIgmWvp8-izw.png</url>
            <title>Stories by Cafe Babe on Medium</title>
            <link>https://medium.com/@0xd0cf11e?source=rss-137f3b654279------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:41:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0xd0cf11e/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[Analyzing Emotet with Ghidra — Part 2]]></title>
            <link>https://medium.com/@0xd0cf11e/analyzing-emotet-with-ghidra-part-2-9efbea374b14?source=rss-137f3b654279------2</link>
            <guid isPermaLink="false">https://medium.com/p/9efbea374b14</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[ghidra]]></category>
            <category><![CDATA[emotet]]></category>
            <dc:creator><![CDATA[Cafe Babe]]></dc:creator>
            <pubDate>Mon, 22 Apr 2019 23:29:18 GMT</pubDate>
            <atom:updated>2019-04-22T23:29:18.629Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analyzing Emotet with Ghidra — Part 2</h3><p>This post is a continuation from <a href="https://medium.com/@0xd0cf11e/analyzing-emotet-with-ghidra-part-1-4da71a5c8d69">Part 1</a>.</p><p><strong>SHA256:</strong> <strong><em>ee0a206415cce60f8b3afb29d8c17f86fe1923cbdf69812be139a3012b2fa24b</em></strong></p><p>A quick recap: Part 1 was an introduction into of using Ghidra as a tool to statically reverse engineer Emotet. Emotet encoded their strings with a simple xor. Since the xor routine was used throughout the file, I showed how I used Ghidra’s script manager to write a python script to automate decoding the strings.</p><p>For Part 2, the challenge was to see if I could do something similar to decode the API names that Emotet encoded as a hash value.</p><h3>How does Emotet resolve the API addresses?</h3><p>The Malware doesn’t have encrypted strings of the API names in its binary. Instead it has the API name stored as hash values in the binary.</p><p>These array of hash values are pushed onto stack and are referenced by a pointer used in the function <strong><em>0x401230</em></strong>. I’ve labeled the function as <strong><em>decodeAPINames</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*bGFSGxCvx_4Mmw24AoDcSA.png" /><figcaption>1. A snippet of hashes pushed onto stack</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*WOIV-Fu7F3qwDkq-oXTirg.png" /><figcaption>2. Other parameters passed to function</figcaption></figure><p>First a handle to the DLL is gotten before the call to <strong><em>decodeAPINames</em></strong> is made. The malware finds the handles for kernel32.dll and ntdll.dll by enumerating through <strong><em>PEB</em></strong>. And the rest of the DLLs are loaded with <strong><em>LoadLibraryW</em></strong> (the DLLs names were encoded by the xor routine).</p><p>The function uses this handle to read the <strong><em>Export Address Table</em></strong> of the DLL. It hashes each API name in the table and compares it to the hash values pushed onto stack. If it matches, the API address is saved to an offset in the file.</p><p>Side-note: Not all the hashes are useful. Some are dummy hashes so it appears that the file has a gargantuan list of API addresses to resolve and thus meant to confuse the analyst.</p><h3>Getting the names from the hashes with Python</h3><p>Here is the script I’ve written so you can follow along — <a href="https://github.com/0xd0cf11e/ghidra/blob/master/ghidra_emotet_decode_hash.py">https://github.com/0xd0cf11e/ghidra/blob/master/ghidra_emotet_decode_hash.py</a></p><p>There are different ways that one can tackle this. The method I employed requires interaction by the user and the user having a list of the API names in a file ready. This made it easier for me to write a simple script, though it requires some preparation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*k-cNhlOp4h3GtWjeVc14Jg.png" /><figcaption>3. A part example of API names from Kernel32</figcaption></figure><p>First, I wrote a quick <a href="https://github.com/0xd0cf11e/pefile/blob/master/exportFunctions.py">script</a> to get all the export functions of a DLL to a file.</p><p>I ran the script over <strong><em>ntdll.dll</em></strong>, <strong><em>kernel32.dll</em></strong>, <strong><em>advapi32.dll</em></strong>, <strong><em>shell32.dll</em></strong>, <strong><em>crypt32.dll</em></strong>, <strong><em>urlmon.dll</em></strong>, <strong><em>userenv.dll</em></strong>, <strong><em>wininet.dll</em></strong>, <strong><em>wtsapi.dll</em></strong>.</p><p>Next was to find all the offsets where <strong><em>decodeAPINames</em></strong> is referenced. For this I came across Ghidra’s Java script <strong><em>ShowCCallScripts.java</em></strong> in the <strong><em>Script Manager</em></strong>. As the script mentioned, I placed the cursor in the <strong><em>decodeAPINames</em></strong> function and ran it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*IJj6mTetlJqsN8des3FjJg.png" /><figcaption>4. Console output after running ShowCCallScripts.java</figcaption></figure><p>For running the script, all I had to do was note which referenced offset was resolving API names for which DLL. <br>For example, the function at <strong><em>0x4079c0</em></strong> resolves for <strong><em>crypt32.dll</em></strong> API names. I know this since I can see that name was decoded at <strong><em>0x407afa</em></strong> when the call to <strong><em>decode_strings</em></strong> was made (if you read <a href="https://medium.com/@0xd0cf11e/analyzing-emotet-with-ghidra-part-1-4da71a5c8d69">Part 1</a>). It then calls <strong><em>decodeAPINames</em></strong> at offset <strong><em>0x407b3a</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*iVfzLs2pPO8V_j1Rl4NwVg.png" /><figcaption>5. Prompt asking for offset referencing <strong>decodeAPINames</strong><em>.</em></figcaption></figure><p>When the script is run, it prompts for the offset. Continuing from the example I enter <strong><em>407b3a</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*ggBdD5jFjsqO7i7UwYU1Ig.png" /><figcaption>6. <strong>crypt32.list</strong> file containing list of <strong>crypt32.dll</strong> export function names.</figcaption></figure><p>Next it prompts for the file and I select the file I’ve created having the export function names from <strong><em>crypt32.dll</em></strong>.</p><p>In the console we see what API names got resolved. In the case of <strong><em>crypt32.dll</em></strong>, there is only 1 API name <strong><em>CryptDecodeObjectEx</em></strong> despite 39 (0x27 in hex) hashes being pushed onto stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*vcFx9rk6TBrLja6riiPL2A.png" /><figcaption>7. Console result</figcaption></figure><p>And accordingly the script labels the offset with the API name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*TgYSCQadFQcEwvtUxsAYxw.png" /><figcaption>8. <strong><em>CryptDecodeObjectEx</em></strong> label created.</figcaption></figure><p>Below is one run for kernel32.dll:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*1IIy65k-lR828vAOYzvueQ.png" /><figcaption>9. API names for kernel32</figcaption></figure><p>Hope this has inspired you. If you have found a better way to decode the hashes or some other cool techniques with Ghidra, please feel free to share :).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9efbea374b14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing Emotet with Ghidra — Part 1]]></title>
            <link>https://medium.com/@0xd0cf11e/analyzing-emotet-with-ghidra-part-1-4da71a5c8d69?source=rss-137f3b654279------2</link>
            <guid isPermaLink="false">https://medium.com/p/4da71a5c8d69</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ghidra]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[emotet]]></category>
            <dc:creator><![CDATA[Cafe Babe]]></dc:creator>
            <pubDate>Fri, 19 Apr 2019 02:15:56 GMT</pubDate>
            <atom:updated>2019-04-22T23:36:34.549Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analyzing Emotet with Ghidra — Part 1</h3><p>This post I’ll show how I used Ghidra in analyzing a recent sample of Emotet.</p><p>If you have read this, here is <a href="https://medium.com/@0xd0cf11e/analyzing-emotet-with-ghidra-part-2-9efbea374b14">Part 2</a>.</p><p><strong>SHA256:</strong> <strong><em>ee0a206415cce60f8b3afb29d8c17f86fe1923cbdf69812be139a3012b2fa24b</em></strong></p><p>The analysis is done on the unpacked binary file. In this post I’m skipping how I unpacked the file, since what I primarily want to show is how I used Ghidra’s python scripting manager to decrypt strings and API calls.</p><p>Some short descriptions:</p><p><em>What is Ghidra?</em></p><ul><li>It is an open source reverse engineering tool suite. You can find out more here — <a href="https://ghidra-sre.org/">https://ghidra-sre.org/</a></li></ul><p><em>Why Emotet?</em></p><ul><li>Emotet is a prevalent malware. Started out as a banking trojan. It is persistent and keeps evolving its infection mechanisms. There are other existing analyses done. A search can lead you there — <a href="https://www.google.com/search?q=emotet">https://www.google.com/search?q=emotet</a></li></ul><p><em>Why Ghidra and Emotet?</em></p><ul><li>For starters, I am looking for a new gig (a.k.a unemployed) and hence cannot afford an <a href="https://www.hex-rays.com/products/ida/">IDA Pro license</a>. Plus I want to continue being a Malware Analyst.</li><li>Using the free version <a href="https://www.hex-rays.com/products/ida/support/download_freeware.shtml">IDA v7.0</a> is still amazing, but I miss not being able to use IDA Python. I did use IDA’s own scripting language IDC but…I like python. Implemented just one of the functions of Emotet <a href="https://github.com/0xd0cf11e/idcscripts/blob/master/emotet/emotet-decode.idc">here</a>.</li></ul><h3>Opening up Emotet with Ghidra</h3><p>Ghidra is about creating projects. Following the on-screen instructions, I created a project named “Emotet”. To add files to analyze into the project, simple type <strong><em>I</em></strong> or go to <strong><em>File -&gt; Import File</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*E5OL8SaICJdzYYZL" /><figcaption>1. Imported Emotet binary</figcaption></figure><p>Ghidra displays properties regarding the file that gets imported. Double click on the file name and it opens it up in CodeBrowser which is a tool that disassembles the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-dYcgfOi2lBEyddmGDGetQ.png" /><figcaption>2. Emotet view in CodeBrowser</figcaption></figure><p>Under the Symbol Tree (usually on the left or you can go to <strong><em>Window -&gt; Symbol Tree</em></strong>), I filtered for “entry” to get to the binary’s entry point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Cx2ecow7CG43KSTVRvENw.png" /><figcaption>3. Entry Point of Emotet</figcaption></figure><p>Under Listing we see the compiled code and on the right is its decompiled code. Since I’ve already analyzed these binaries, some of the sub routine calls and offsets in these images will have been renamed by me. To rename an offset, right-click an offset value and select <strong><em>Edit Label</em></strong> (or type <strong><em>L</em></strong>).</p><h3>Emotet’s Function Calls</h3><p>Emotet encrypts its strings and stores its API call names as hashes. So statically viewing this file, is a pain to read.</p><p>Without going into much detail about Emotet’s payload (that would require another blog entry), I will show how to make this binary a bit more easy to follow. It does require to initially go through each function and figure out the math (possibly using <strong><em>Olldbg</em></strong>, <strong><em>Wingdb</em></strong> or whichever debugger so to make it a little less painful).</p><p>In this case I wanted to figure 2 methods used by Emotet. The first function is a simple xor routine that it uses to decrypt strings. It looked deceiving complex (because of the use of shift operators in the function), only till after running one iteration in <strong><em>Ollydbg</em></strong> that I realized what was happening… . The second function finds which API name matches which hash (I will cover this in <a href="https://medium.com/@0xd0cf11e/analyzing-emotet-with-ghidra-part-2-9efbea374b14">Part 2</a>). This I felt was a bit more clever, but still easy to understand after running in <strong><em>Ollydbg</em></strong>.</p><p>Then using Ghidra’s Script Manager, I’ll show how I implemented the python scripts to decrypt the strings and resolve the API calls used in the binary.</p><h3><strong>How are the Strings encrypted?</strong></h3><p>In the binary, I’ve noticed a lot of references to the function call at <strong><em>0x00401b70</em></strong>. This call decrypts for the strings. I renamed it to <strong><em>decode_strings</em></strong>. To find references made to the function, right click the function and select <strong><em>References -&gt; Show References to</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*kxwArf6wqvHJgne1" /><figcaption>4. References to decode_strings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*cC1qK9e0UcSpckWF" /><figcaption>5. Call being made to decode_strings</figcaption></figure><p>The function <strong><em>decode_strings</em></strong><em> </em>takes in 2 arguments that are stored in <strong><em>ECX</em></strong> and <strong><em>EDX</em> </strong>(Image 5). <strong><em>ECX</em></strong> is the offset of the encrypted string. <strong><em>EDX</em></strong> is the xor key. The decrypted string gets stored in memory allocated in the heap and the address gets passed to <strong><em>EAX</em></strong>.</p><p>(Side Track: I have added the string “<em>ecx = offset \n edx = key</em>” as a repeatable comment to the function. Right click the address and select <strong><em>Comments -&gt; Set Repeatable Comment</em></strong> or type <strong><em>;</em></strong>)</p><p>The first dword at the offset xor’ed with the key returned the length of the string. The next subsequent set of dwords were xor’ed up until the string’s length.</p><p>Now for the more exiting part, automating this with a python script in Ghidra.</p><h3>Using Python to Automate Decryption</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/25/1*KCLdRqA8rh6EUOEu2J4ahg.png" /><figcaption>6. Script Manager Icon</figcaption></figure><p>In the top toolbar section of Ghidra, we see this icon in image 6. It takes us to the Script Manager. Else you can select <strong><em>Window -&gt; Script Manager</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GpCMXHO7W5HTV3MkoDDsQw.png" /><figcaption>7. Script manager</figcaption></figure><p>The Script Manager displays a list of scripts written in either Java or Python. They come with the installation. The script manager also has some python script examples. So, I filtered for .py scripts to help me understand how to proceed in writing a python script. The Python Interpreter interacts with Ghidra’s Java API through <a href="https://www.jython.org/archive/21/docs/whatis.html">Jython</a>. The documentation on the Java APIs provided can be found in a zipped file in the docs directory of your Ghidra installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/26/1*OQNLnpOkVWYdYd5O8fifYQ.png" /><figcaption>8. Create new script icon</figcaption></figure><p>To create a new python script, select this icon — image 8. Select Python and enter a name you’d like to give to your script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCWmP5g41QE4Ktp9y5L4Qg.png" /><figcaption>8. A sample test.py script created</figcaption></figure><p>Additionally, going through the help docs (under <strong><em>Help -&gt; Contents</em></strong>)<strong> </strong>and reading under <strong><em>Script Development</em></strong>, there is a description of the metadata tags that gets generated when creating a new script.</p><p>I’ve uploaded the script into my github repo and you can follow it here — <a href="https://github.com/0xd0cf11e/ghidra/blob/master/ghidra_emotet_decode_strings.py">https://github.com/0xd0cf11e/ghidra/blob/master/ghidra_emotet_decode_strings.py</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*H_UK5gIcY64GuJYeiIQFwQ.png" /><figcaption>9. Decrypted string displayed as comment</figcaption></figure><p>The idea behind the script is to display the strings that get decrypted as comments next to the instruction where its offset is moved to <strong><em>ECX</em> </strong>(Image 9).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*4eBVLAnJOp9vu0xtipAvZA.png" /><figcaption>10. Bytes patched in the binary.</figcaption></figure><p>And as well to patch the bytes in the binary (Image 10).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*dbC3Qv4j8_de-DPMRaL-uw.png" /></figure><p>First step, I wanted to find all the code references made to the <strong><em>decode_strings</em></strong> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*ll0e0K5Px1LpZsLWzQEUEg.png" /></figure><p>Iterating through each reference, the next step was locating for the opcode instructions <strong><em>MOV ECX</em></strong> and <strong><em>MOV EDX</em></strong>. The instructions weren’t always immediately before the call to the function. So I iterated through a max of 100 instructions to search for the opcodes.</p><p>After that I was all set to carry out the xor routine and patch the bytes and comment at the instruction offset where <strong><em>MOV ECX</em></strong> was carried out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4da71a5c8d69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1: Banking Trojan — Jar, Delphi]]></title>
            <link>https://medium.com/@0xd0cf11e/part-1-banking-trojan-jar-delphi-21cbef90d6e4?source=rss-137f3b654279------2</link>
            <guid isPermaLink="false">https://medium.com/p/21cbef90d6e4</guid>
            <category><![CDATA[delphi]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Cafe Babe]]></dc:creator>
            <pubDate>Thu, 22 Dec 2016 23:48:47 GMT</pubDate>
            <atom:updated>2016-12-22T23:48:47.461Z</atom:updated>
            <content:encoded><![CDATA[<p>The malware starts of as a jar file. It typically enters a user’s machine as a malicious attachment in an email. This first segment of the article covers the execution routine starting from the jar file to the final Delphi DLL that has the main payloads. The payloads will be analysed in part 2.</p><h3>The Layout</h3><p>The java code has encrypted strings and obfuscated variable/function names. The obfuscated names are long, which make it difficult for the analyst to read the code with ease. However, there is a pattern in the way the variables/functions are named. By removing certain string patterns that are observed (Figure 1), we can see the actual names more clearly (Figure 2). We can also see the occurrence of Portuguese words being used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*yaBW5d9dpB89jSZ6e3LyQg.png" /><figcaption>Figure 1: Obfuscated Names</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*ZHxiBhsbzcs_c-yklO6BVw.png" /><figcaption>Figure 2: Unobfuscated Names</figcaption></figure><p>Figure 3 shows the encrypted strings in the code. Figure 4 shows the decryption routine used. Integer cCod acts as a key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*rFRYjBs4zjqzNsNdBdzoqw.png" /><figcaption>Figure 3: Encrypted Strings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*w2FMa9bta90xBHsCcer29w.png" /><figcaption>Figure 4: Decrypt Strings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*21pKjz8-FgFWSe62g73XOQ.png" /><figcaption>Figure 5: What the jar downloads/creates</figcaption></figure><p>The jar chooses “C:\Users\Public” as the root directory to download/create files (Figure 5).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*7mOmf2U5DtDmH_zd0Tx-vQ.png" /><figcaption>Figure 6: File x and Random Name Folder</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*60x1CX3q6ZAnAcwoOfhWpw.png" /><figcaption>Figure 7: Files inside the malicious folder</figcaption></figure><p>A file “x” is created under the “C:\Users\Public” directory (Figure 6). It creates a folder in the same directory with a random name (Figure 6). After that it downloads 3 files from its server into the folder. The files arrive as zipped files which it unzips and assigns them with a random name and random extension. The random name and extension generated for the files are the same with the excepted of the names being followed by a number (Figure 7). This is how the malware makes sure which file gets executed first.</p><p>In figure 8 we can see how the names are generated. Translating the variable names from Portuguese, sNomePasta is Folder Name, sNomeArq is File (“Arquivo” in Portuguese) Name, and the third is self-explanatory is File extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*iy_arYcdC5PxV7fglGpPyA.png" /><figcaption>Figure 8: Generating Names</figcaption></figure><p>It also confirms if the directory “C:\Program Files (x86)\” exists, which would indicate that the machine is 64-bit. If it is 64-bit, the file downloaded as &lt;sNomeArq4.sNomeExt&gt; is different.</p><h3>File Contents</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/153/1*xBLX4Tln_mzsh09PtK-yng.png" /><figcaption>Figure 9: File x</figcaption></figure><p>The file “x” created is how the malware keeps track of the random names it has created. It stores 5 values in the file (Figure 9). The first value is usually 0. In part 1 of the analysis, there was no indication of it being used. The second value is the cCod we saw used in encrypting/decrypting the strings. The 3rd value is the encrypted sNomePasta, followed by the encrypted sNomeArq and the encrypted sNomeExt.</p><p>The files “id” and “idw” are used in part 2 of the analysis.</p><p>&lt; sNomeArq1. sNomeExt&gt;, &lt; sNomeArq2. sNomeExt&gt; and &lt; sNomeArq4. sNomeExt&gt; are Delphi DLL files. &lt; sNomeArq1. sNomeExt&gt; is an encrypted binary that gets decrypted by &lt;sNomeArq4.sNomeExt&gt;.</p><h3>Order of Execution</h3><p>The jar first executes &lt;sNomeArq2. sNomeExt&gt; with the following command line:</p><p><em>cmd.exe /c regsvr32.exe /s “c:\users\public\sNomePasta\sNomeArq2.sNomeExt” #90</em></p><p>“regsvr32” is used for registering DLLs in the Windows Registry. It is run using the silent option to registry the malicious DLL in the registry “<em>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run”</em>. So now the DLL will get executed every time the machine starts up. #90 is the cCod passed as parameter to the DLL.</p><p>&lt;sNomeArq2. sNomeExt&gt; confirms if the parameter passed is the valid cCod. It validates this by using it to decrypt a string and seeing if it matches with the string “omega”. If not, it terminates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*ZoLuFDNhRXalQt_m-LDadA.png" /><figcaption>Figure 1o: Injection Process</figcaption></figure><p>It then iterates through the processes for “explorer.exe”. Once it gets the process id, it uses it to allocate a dynamic memory in the explorer process. This memory contains the string that is the path to one of the DLLs, &lt;sNomeArq4. sNomeExt&gt; (Figure 10).</p><p>After which it creates a remote thread in the explorer process through the API CreateRemoteThread. The thread invokes the API LoadLibraryW in “explorer.exe” passing the buffer with the path string as the parameter. This in turn loads the other malicious DLL in the explorer process.</p><p>When executed, &lt;sNomeArq4. sNomeExt&gt; creates a thread that decrypts the binary &lt;sNomeArq1. sNomeExt&gt;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*9wPOCiGBFV5Ws66uT15aHg.png" /><figcaption>Figure 11: Decryption Pseudocode</figcaption></figure><p>The first byte in the binary is the key. Figure 11 explains the decryption routine is pseudocode.</p><p>After decryption, &lt;sNomeArq1. sNomeExt&gt; is a Delphi DLL that has the main payloads (Figure 12). It gets loaded into memory by &lt;sNomeArq4. sNomeExt&gt;. In part 2 of the analysis, we shall see more about what the payloads do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*0UN9MlW3ai_-E_GiqZcuQQ.png" /><figcaption>Figure 12: Delphi Method Offsets — pointing to different payloads</figcaption></figure><h3>References:</h3><p><strong>SHA1s used:</strong></p><p>4dfd76d45ca065eb4686320c6a41895ea7b56d22</p><p>5e587ff96d733604d03cd6709110f9bce7395aa3</p><p>7a77557e08f40bb5ba37c64d96adf817618d70bc</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21cbef90d6e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>