<?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 StuckinVim on Medium]]></title>
        <description><![CDATA[Stories by StuckinVim on Medium]]></description>
        <link>https://medium.com/@stuckinvim?source=rss-e9251fb7692c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*CyY9-8NULLGeRoI8MDNFXw.jpeg</url>
            <title>Stories by StuckinVim on Medium</title>
            <link>https://medium.com/@stuckinvim?source=rss-e9251fb7692c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:03:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stuckinvim/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[URSNIF Banker Revealing The Evil Part 1]]></title>
            <link>https://medium.com/@stuckinvim/ursnif-banker-revealing-the-evil-part-1-2e7910b66dd7?source=rss-e9251fb7692c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e7910b66dd7</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[ghidra]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[StuckinVim]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 17:34:21 GMT</pubDate>
            <atom:updated>2019-03-15T17:36:45.693Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROjwPcVm9Auzgb98nw1QxA.jpeg" /><figcaption>Thousands of years ago when Ghidra was in the planning/design stage</figcaption></figure><p>If you have been following me for a while <a href="https://twitter.com/AGertani">@AGertani</a> you would know that I&#39;m head to toes with tracking URNSIF/GOZI and unpacking it, URSNIF or GOZI ISFB have been discovered by Cisco Talos and is predominantly active since 2013 <a href="https://blog.talosintelligence.com/2016/09/goznym.html#more">https://blog.talosintelligence.com/2016/09/goznym.html#more</a> especially after the leaked source of the ISFB module and remains of one of the hottest malware leaks out there <a href="https://github.com/gbrindisi/malware/tree/master/windows/gozi-isfb">https://github.com/gbrindisi/malware/tree/master/windows/gozi-isfb</a></p><p>In this write up series I will try to my best cover the way it will decrypt it self through various stages all the way to the ISFB dynamic link library final implant URSNIF delivers and hopefully it will be throughout multiple post series to avoid any confusion in tracking the staging process.</p><p>This post will only target stage 2 unpacking and decryption process.</p><p>It has been almost a week since release of Ghidra reverse engineering tool to open source by the NSA and it will be the disassembler of choice in this series and x64dbg as the debugger, if you haven&#39;t downloaded Ghidra yet I really recommend it as this tool offers incredible resources for reverse engineering, you can find it here <a href="https://ghidra-sre.org/">https://ghidra-sre.org</a></p><p>And if you are relatively new to unpacking malware I recommend this great paper by Mark Vincent Yason <a href="https://www.blackhat.com/presentations/bh-usa-07/Yason/Whitepaper/bh-usa-07-yason-WP.pdf">https://www.blackhat.com/presentations/bh-usa-07/Yason/Whitepaper/bh-usa-07-yason-WP.pdf</a></p><p>Sample hash <strong>MD5</strong> 5a18b710adf77e347ac2730d1ab066ea</p><p>Sample download link</p><ul><li><a href="https://www.virustotal.com/#/file/dd53507e3c4f29bb41a23090550aeee4f59131d85a87a6f7ae9f818f4c0459a4/detection">VirusTotal</a></li><li><a href="https://malshare.com/sample.php?action=detail&amp;hash=5a18b710adf77e347ac2730d1ab066ea">MalShare</a></li></ul><p>The bas address for elements will be treated as 0x0 though out this series.</p><p><strong>From “VirtualProtect” to “Call EAX”</strong></p><p>After downloading the sample the immediate red flag during the static analysis of the PE import table is the <em>“GetProcAddress” </em>API <a href="https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-getprocaddress">https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-getprocaddress</a> and the <em>“GetModuleHandleA” </em>from Kernel32 library where URNSIF will attempt to dynamically import memory management APIs from modules already loaded in the process such as Kernel32.dll in order to facilitate the unpacking process, This dynamic API resolution technique is very popular with malware in order to avoid technique discovery during static analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiA1MNagVNHPWGTxSE5cPw.png" /></figure><p>At this point popular memory management APIs and especially the <em>Virtual Memory Management Functions </em>exported by Kernel32.dll <a href="https://docs.microsoft.com/en-us/windows/desktop/Memory/memory-management-functions">https://docs.microsoft.com/en-us/windows/desktop/Memory/memory-management-functions</a> are a target of analysis and its very important to set a break point on <em>“GetProcAddress” </em>API and investigate further the result of this dynamic resolution.</p><p>After recognizing the technique the question is where is this trick used in the binary and Ghidra is here to help with looking for references to “<em>GetProcAddress”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Z1BNVLb15WM7H0VnCPndw.png" /><figcaption>References to GetProcAddress API as seen on Ghidra</figcaption></figure><p>From the references information given from above result we see that 0xB1F1 we will dynamic resolve an API and then call it through a “Call EAX” instruction, it important to figure out what the return of the call to Get “<em>GetProcAddress” and </em>a breakpoint on the API could be of agreat help.</p><p>In the view from X32dbg below the breakpoint on <em>“GetProcAddress”</em> API resulted in revealing the dynamically imported virtual memory management API “<em>VirtualProtect”</em> but why? changing the access rights is the purpose here <a href="https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-virtualprotect">https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-virtualprotect</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zltnHp5vpyzOJUpiNSRyRA.png" /></figure><p>Resorting to Ghidra to understand the value of this dynamic resolve is important before stepping further in the debugger, and the function flow seen below indicates to nothing more than a attempt to change the access rights to a certain section, setting break point on “<em>VirtualProtect” </em>would help a great deal through out the whole unpacking process now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNGw5-Y7lzzyEhd1hOPEiA.png" /><figcaption>Dynamic Cal to VirtualProtect though CALL EAX in function 0xb1f1</figcaption></figure><p>After setting the break point on <em>VirtualProtect </em>stepping though the debugger to grab the call to the API dynamically through the “Call EAX” shown above from the Ghidra disassembly would help finding the target section that is a subject to an access right change to 0x40 “EecuteReadWrite” <a href="https://docs.microsoft.com/en-us/windows/desktop/Memory/memory-protection-constants">https://docs.microsoft.com/en-us/windows/desktop/Memory/memory-protection-constants</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUtRfmh1YPjJKGdX_mZPAQ.png" /></figure><p><strong>From Decryption to “CALL ESI”</strong></p><p>After the rights change process, in function 0xB1F1 the target section remains in its decrypted state where URSNIF needs to decrypt the section and to do that it will continue the execution flow to function 0xb56d where the function will decrypted the target range in the data section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aI-GMbWur3DbVr-N5Leskw.png" /><figcaption>Call to Decrypted Data section in 0xB56D after decryption</figcaption></figure><p><strong>Decryption Decryption Decryption and a confused debugger</strong></p><p>After stepping in the “CALL ESI” instruction that will transfer execution to the target “Data Section starting at 0xA5A8” and the function contains a single call that will lead to a call to 0xAAA2 that would eventually contain a “JMP EAX” to the unpacking stub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5X8yeMoUy073zkJM9tCNiQ.png" /><figcaption>First Decrypted function of the Data section contains the correct call in Ghidra</figcaption></figure><p>Before stepping through the execution its seems that while the execution should continue through to 0xAAA2 like the snippet from Ghidra Above, X32dbg disassembler is still confused in a sense that the graph view in x32dbg below at contains the wrong assembly where it contains a jump to 0xAA49 instead of 0xAAA2 like highlighted in the snippet above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*aKqzX-Hggjy2SEFIPW1usA.png" /><figcaption>Above we can see that 0x40aa9d contains the wrong jump before decryption</figcaption></figure><p>This could be solved by running “LOOP 0x0A5C5” in order to allow the function to decrypt the proceeding section and transfer execution to it, and once the decryption process is done step through the the execution path and the instruction will change the jump in 0xAA9D and pass the execution to 0xAAA2 instead of 0xAA49.</p><p><strong>A Suspicious JuMp from the Data Section</strong></p><p>At this point after the related part in the data section has been decrypted and further maintain a consistency between the debugger and the disassembler dump the live debugged process from memory in order to locate and disassemble the decrypted ERW data section and see where those function would lead to hopefully locate the unpacking stub, to do this in x64dbg Scylla plugin <a href="https://github.com/x64dbg/ScyllaHide">https://github.com/x64dbg/ScyllaHide</a> could be be used to dump the live process memory attached to the debugger and reload it again in Ghidra</p><p>After dumping the live process memory reload it again in Ghidra and navigate to the to data section to function 0xAAA2 the below instruction set will serve as the last step before transferring execution to the unpacking stub through “JMP EAX”</p><p>The function will utilize MOVSB REP instruction to somewhat serve a similar role to a memcpy() function to transfer the unpacking stub to its new location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2YF339RFBQMZZ8wFQAGypg.png" /></figure><p><strong>The unpacking stub</strong></p><p>At this point it would be very useful to disassemble the stub in Ghidra and to do that basically dump the unpacking stub binary and add it as a new section in the dumped URSNIF sample from the step earlier, and now you have the unpacking stub and the decrypted data section in the same binary Nice!</p><p>Below is the snapshot after adding a new section to the PE in PEBear by HasherZade <a href="https://hshrzd.wordpress.com/pe-bear/">https://hshrzd.wordpress.com/pe-bear/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwxKfqB6BqTrZeQEdJOFoA.png" /><figcaption>PEBear is Great tool to manipulate PEs and add or remove new section to them</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*j_WCU9oivGkvyOID6eAP_Q.png" /></figure><p>After reloading the binary again in Ghidra navigate to the unpacking stub the program trees section in Ghidra and it should look like the below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*hK-YgzhqC6QOMMq2eudauQ.png" /><figcaption>Stage 2 unpacking stub in Ghidra</figcaption></figure><p>The main purpose of the the unpacking stub is to allocate memory for stage 2, decrypt stage 2 binary and replace the original stage 1 binary with stage 2 and transfer the execution back to the .text section.</p><p><strong>Decryption and one nasty trick</strong></p><p>But the trick here is that not all of the newly allocated binary contains the stage 2 binary, as a mean of “Anti Analysis” the stage 2 binary will contain a an extra over lay just before the MZ header and that would confuse tools that would look for an MZ header in the returned address from a “<em>VirtualAlloc” </em>call <a href="https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-virtualalloc">https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-virtualalloc</a></p><p>Before the beginning of the decryption operations the unpacking stub will allocate memory to the stage 2 Binary through a dynamic call to “<em>VirtuallAlloc” </em>and from there write an encrypted binary to the new location and once that is successful the decryption operations begin.</p><p><em>Decryption Function 1 0x2dc</em></p><p>This function will mostly work on decrypting the binary buffer and find where the actual stage 2 binary might start and in this case it is 0x991 and that will be decryption function 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KToAuN2qH19JCusClo3Keg.png" /><figcaption>Memory is allocated to stage 2 binary and once that is successful its passed to Decryption function 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UENKjamwNNe1vmCoQ8OhNQ.png" /><figcaption>Stage2 binary before decryption</figcaption></figure><p><em>Decryption function 2 0x2ae</em></p><p>This function will start working on decrypting the newly allocated stage 2 binary but starting with the address of the real MZ header among the whole section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yB5MFE6jUHrnM9LoWMUZlw.png" /></figure><p><em>Decryption function 3 0x190</em></p><p>In this function the binary will fully decrypt and the stage 2 binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2MjfStmExlEIb5hQ9ZxxQ.png" /><figcaption>Last decryption phase of stage 2 Binary</figcaption></figure><p>Following the base address of the newly allocated binary after the successful decryption the clear MZ header will be of course located at “Stage2BaseAddress + 0x991” = MZ header like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CtrRlTKZxG79ltkrZKSxgA.png" /><figcaption>stage 2 binary After Decryption the MZ header is visible</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*Mg5sZF4_rKlQqmnwY55tDg.gif" /><figcaption>we can see the stage 2 decrypted binary coming to life after completing the decryption</figcaption></figure><p>After the successful decryption of stage 2 copy the whole new section where stage 2 resides and move it to the desktop in the VM order to remove the excess gibberish binary preceding the PE header at 0x991 section in order to load it in a Ghidra again to understand it further, while the decrypted binary will be visible it will contain an excesses meaningless header that you need to get rid of like below, a good hex editor will do the job and I&#39;m using the free HXD hex editor below to cut out the excess binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lorEb18eLKbS3hxEda28aw.png" /></figure><p><strong>Revealing the Evil</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*VAojf9Hwf63sl_AxGG5uXA.gif" /><figcaption>Ghidra!</figcaption></figure><p>In order to confirm stage two successfully after loading it in Ghidra and the entry function should look like the below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QKUOeYQ4wO9DCjsS2IiKcQ.png" /><figcaption>The entry point of the stage 2 binary of Mar-3–2019</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2lXAB7zb7csZL9w20_zkQ.png" /><figcaption>ISFB date is visible in Stage 2 binary</figcaption></figure><p>Below is a comparison of the entry point point between Mar-3–2019 sample and Jan-28–2019 sample where the entry point and the follow up functions are exactly the same</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3xbWjjBVVEeG_w82jEN-g.png" /><figcaption>Mar-3–2019 Stage 2 Entry Point</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18QtyGchIqr0BCThdVa21Q.png" /><figcaption>Jan-28–2019 Stage 2 Entry Point</figcaption></figure><p>I will stop here where the next part of this series ( hopefully!) I will get into the details of how the stage 2 will replace the stage 1 binary and transfer execution back to it through the unpacking stub itself.</p><p>If there is any thing I can do to make this series of a greater value feedback is indeed welcome and you can reach me directly me <a href="https://twitter.com/AGertani">@AGertani</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e7910b66dd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scrape Malware Off of The Face of Your Enterprise]]></title>
            <link>https://medium.com/@stuckinvim/scrape-malware-off-of-the-face-of-your-enterprise-4686ec5d7e74?source=rss-e9251fb7692c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4686ec5d7e74</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[threat-intelligence]]></category>
            <dc:creator><![CDATA[StuckinVim]]></dc:creator>
            <pubDate>Sat, 26 Jan 2019 23:32:11 GMT</pubDate>
            <atom:updated>2019-01-26T23:32:11.653Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*pwVOR2H7YbwXSjtTQMv2Ug.jpeg" /></figure><p>If you are like me working as a blue teamer in an environment of thousands of users, endpoints, servers and with somewhat hundreds of admins with countless domain admin rights here and there.</p><p>You often ask yourself “Is it possible that there isn’t any malware beaconing out of our environment as we speak?’</p><p>“Is dormant malware ready to serve further attacks whenever adversaries feel like it?”</p><p>“Do we have to wait for that supply chain attack to be all over the headlines till we do something about it ? “</p><p>“Our AV and EDR vendors are reporting the malware they can see they what about the malware they couldn’t?”</p><p>“How effective is our EDR of choice? How can we test their durability over time?”</p><p>Well from time to time we hear about plans of defense in depth where large attack surface corporation attempt to install more than one AV EDR agent to minimize the risk, but we all know the amount of operational overhead the desktop supports groups and the applications demand for power.</p><p>Well my own version of an answer to this dilemma is “Threat Hunting”, but if you re wondering where to start in this mess of an environment, bear with me because “The Hunts Are Coming”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*qNBX-SMOWsTifKGR0ZxW-A.jpeg" /></figure><p><strong>Windows Application Compatibility “Shimcache”</strong></p><p>Let’s face it application whitelisting is every CISO’s wild dream that would soon be doomed after the operational overheads and the countless ticket of application requests by the software download hungry development teams and system admins.</p><p>No time should be wasted in thinking of a threat hunting program is luxury or a solid need, we need real threat hunting programs to examine our environment against emerging threats.</p><p>I will not go through the ShimCache subject for the sake of time but if you are interested to learn more here you go <a href="https://countuponsecurity.com/2016/05/18/digital-forensics-shimcache-artifacts/">https://countuponsecurity.com/2016/05/18/digital-forensics-shimcache-artifacts/</a></p><p><strong>What is AppcompatProcesser</strong></p><p>In this post I will review a great tool or more like a framework written by @MatiasBevilacqua and FireEye released for open source, The AppcompatProcessor is a great threat hunting framework that allows “Threat Hunters” to look at the big picture of Malware foot print, adversaries trail and may just maybe... uncover a possible breach! (pun intended)</p><p>AppcompatProcessor will help “Hunters” ingest the Shimcache and Amcache data that exist in the Windows application compatibility hives across thousands of endpoints and servers.</p><p>For the best performance I recommend to run the tool on Ubuntu or MacOS unfortunately the tool is currently broken on windows (according to Matis himself I didn’t try installing it on Windows).</p><p>I will be using Ubuntu Bionic in this demo.</p><p>AppcompatProcessor will use multithreading utilizing the maximum core count of the processor.</p><p>In a console execute the below command to pull download the framework directly from GitHub</p><pre>$git clone <a href="https://github.com/mbevilacqua/appcompatprocessor.git">https://github.com/mbevilacqua/appcompatprocessor.git</a></pre><p>Before you start the setup process as recommended by the read.me page you might face problems regarding the libraries related to the framework I recommend installing the below packages that is if you are using Ubuntu with Apt and brew on MacOS could be a great help.</p><pre>$sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev</pre><p>Afterwards follow all the steps recommended in the read.me page written by Matis himself.</p><p>below is the output after successfully running <em>Appcompatprocesser.py -h</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*DYI1eC7irM1W8EMoFv9dNQ.gif" /><figcaption>AppCompat Processor help menu</figcaption></figure><p><strong>Data Set Collection</strong></p><p>Now that we have installed AppcompatProcessor we proceed to collect our data set from the enterprise to digest in our processor, if you go through the READ.me page you will find various data types that could be ingested into the framework my favorite is raw SYSTEM and Amcache.hve from across the enterprise and the Amcache.hve data set is my favorite, for the Amcache.hve the be digested into the data base successfully you must include the host name where the file has been extracted from like “&lt;hostname&gt;.hve” and SYSTEM hive should keep their original name where Appcompat will do the trick and extract the hostname automatically, You can find Amcache hive in the below location</p><p><em>C:\Windows\AppCompat\Programs\</em><strong><em>Amcache</em></strong><em>.hve.</em></p><p>Regarding the collection of the data set across your enterprise network you need to be creative from the use of <em>Python</em> to <em>PowerShell</em> scripts and an adequate careful use of domain admin credentials will do the trick.</p><p>Although experimental data sets of few hosts here and there are good for testing purposes but not to demonstrate the actual scope of the hunt, for your initial data set collection I recommend collecting a set that covers your entire environment, AppcompatProcessor is not your day to day tool of pattern matching tools rather it is inferencing engine that takes advantage of data richness to observe indication of potential compromise and further inferencing from one finding to another to finally paint a full picture of adversaries foot hold in the enterprise.</p><p><strong>Giving Life To Our Data Set</strong></p><p>Below I demonstrate my data set where I attempt to ingest a test set of over 1000 endpoint and we can see how AppcompatProcessor will go through each and every single Amcache file in my data set and create unique host IDs for all the file in the target directory.</p><p>As you will attempt to ingest the data into a data base Appcompat processor will create a new DB and parse all the entries from all over the enterprise in one complete<em> Sql Lite DB</em> file where all the analytics in the framework will be based on.</p><pre><em>$./Appcompatprocessor.py ./</em>Olympus<em>.db load /&lt;path to your amcache hive files&gt;</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*5p_2Fm4jyIGTzBlJilU3EA.gif" /><figcaption>Appcompat Creating unique host IDs for each host with in the data set</figcaption></figure><p>Below is the output of the ingest of my dataset with over 15 million entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*2ie4-SiBFRudl3L9ec9qFA.gif" /><figcaption>Appcompat Proccessor Indexing the Sql DB post parsing the files</figcaption></figure><p><strong>Reconnaissance Scan</strong></p><p>After we have ingested our data set we need to setup the recon index where AppcompatProcessor will go trough the data base looking for indicators of malicious reconnaissance across the where it will inspect for presence of adversary recon attempts within the Appcompat hives.</p><p>Basically AppcompatProcessor will run a cross reference to check a list of key words that are affiliated with internal lateral movement and reconnaissance attempts such as <em>systeminfo.exe , net.exe , net1.exe </em>etc. ( why did Appcompat Processor chose the mentioned commands <a href="https://attack.mitre.org/software/S0039/">https://attack.mitre.org/software/S0039/</a>)</p><p>All these keywords can be found <em>reconFiles.txt</em></p><pre><em>$./AppCompatProcessor.py /Olympus.db reconscan</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZ1Tb5Gyzp4yZHefMub8Tg.gif" /><figcaption>Running Recon Scan on the DB</figcaption></figure><p>After the reconnaissance scan is completed if we run<strong> <em>./AppCompatprocessor.py /</em>Olympus<em>.db list</em></strong><em> </em>we will get a list of the hosts present in our data base with a recon scoring based on the recon trail in the hosts ingested in the DB.</p><p>Th output will be a descending order of the highest risk endpoint to the lowest, and only the endpoint with actual recon string detected will be present in the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EyOvfyJxwHkOyTmIpAnPQg.gif" /><figcaption>Host ID 844 has the highest recon scoring</figcaption></figure><p>Once we have identified the host with the highest scoring we can drill down and display the results that lead to the high score.</p><pre><em>$./AppCompatProcessor.py /Olympus.db Ptcorr “Hostname”</em></pre><p><strong>The Malware Search Module</strong></p><pre><em>$./AppCompatProcessor.py /Olympus.db search</em></pre><p>My favorite function where the Appcompate processor will scan the entire DB searching for malware or trail of malware utilizing a large set of regexes located in the <em>AppCompatSearch.txt </em>file.</p><p>Although the module is already packed with entries, consider adding your own entries based on previous or new incidents within your enterprise will add the value to the <em>Search </em>module so be creative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*s0u6CueEkg_UBK6ZbIO-Cg.gif" /><figcaption>The Search module looking up 15 million entries for Malware</figcaption></figure><p>The output is a histogram of findings in the terminal and detailed results in the generated Output.txt file.</p><p><strong>Temporal Correlation</strong></p><pre><em>$./AppCompatprocessor.py ./Olympus.db tcorr &lt;PE name&gt;</em></pre><p>Unlike the previous module Temporal-Correlation is a non-pattern matching module, as the name implies Temporal correlations will examine the execution cohesiveness in time.</p><p>A normal behavior for Adversaries once they gain foot hold within an enterprise is to explorer their surroundings or bring in additional binary or explore different movement techniques and environmental detection behaviors.</p><p>Temporal-Correlation will allow the hunter to explore the actual result of a certain PE execution with in a time window discovering different weights of execution and whether the correlation execution is in a pivot relation.</p><p>This module could be really useful to hunt for stagers or Malware droppers</p><p><strong>Levenstine Distance Algorithm</strong></p><pre><em>$./AppCompatprocessor.py ./Olympus.db leven</em></pre><p>This algorithm will measure the edit distance between to set of strings in order to identify any deviation from the original file name, after collecting a rich data set we execute the <strong><em>leven</em></strong><em> </em>command and AppcompatProcessor will automatically search for deviations in the system32 folder.</p><p>You can supply any name of your choice and AppcompatProcessor will scan the entire DB for any deviations in the string.</p><pre><em>$./AppCompatprocessor.py ./Olympus.db tcorr &lt;PE name&gt;</em></pre><p><strong>Sql Stack Module</strong></p><p>As the name implies this module will help the analyst initiate searches across the data set based on the query composed by you the results will be displayed in an ascending order of the hit count across the data base.</p><p>In my data set I will launch a search that will search through the tmp folder across the entire enterprise.</p><pre><em>$./AppCompatprocessor.py ./Olympus.db &quot;FileName,FilePath,Sha1&quot; &quot;FilePath LIKE &#39;%tmp&#39;&quot;</em></pre><p>The results will be displayed and all the repeated hits will be aggregated to the bottom where ass will the unique hits will float on top of the results table.</p><p><strong>Shipping Results to Virus Total ( feature not included with AppcompatProcessor)</strong></p><p>After generating the results, we can use the output csv file as the data source to inspect over virus total API.</p><p>If you don’t have a virus total API key you can get one for free if you register your self in virus-total, after you register navigate to setting and that where you will find the API key.</p><p>After normalizing the output into an absolute sha1 values only we will use a custom python script to ship the data to VirusTotal (many are available on GitHub).</p><p>After the script will complete inspecting the hashes csv fill will be automatically generated where we will start inspecting our results for further analysis.</p><p>Any result that reports as a true positive will aid us into more analytics in utilizing the different modules in AppcompatProcessor in further investigation.</p><pre><em>$./AppCompatprocessor.py ./Olympus.db tcorr &quot;True Positive 1&quot;</em></pre><pre><em>$./AppCompatprocessor.py ./Olympus.db tcorr &quot;finding from previous tcorr&quot; -w &#39;input here a wider time window&#39;</em></pre><p>These examples are standard built in the tool, in my opinion as long as the data set is large enough to cover a risk scope then its up to the “Hunter” to be creative and just feel free to compose different queries, investigators should always try to put themselves in the shoes of the adversaries.</p><p>As we reach the end of this writing, I recommend the below video by Matis himself about the tool</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-0bYcD3_bBs%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-0bYcD3_bBs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-0bYcD3_bBs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a8c1b2608203b868d16d87c3805b3b8/href">https://medium.com/media/6a8c1b2608203b868d16d87c3805b3b8/href</a></iframe><p><strong>Now what!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*Etr7M4aVq0OdiBS6131SRg.gif" /></figure><p>Threat hunting is an excruciating and time consuming process, but the active threat hunter is way more capable of responding to incidents in faster manner than your usual reactive analyst because of the awareness the hunter will gain over time.</p><p>Threat Hunting rounds could lead to great insights and help the enterprise design and plan infrastructure security around real findings.</p><p>Happy Hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4686ec5d7e74" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>