{"id":9314,"date":"2024-08-01T22:29:34","date_gmt":"2024-08-01T22:29:34","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=9314"},"modified":"2024-08-01T22:29:34","modified_gmt":"2024-08-01T22:29:34","slug":"high-fidelity-detections-are-low-fidelity-detections-until-proven-otherwise-part-2","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2024\/08\/01\/high-fidelity-detections-are-low-fidelity-detections-until-proven-otherwise-part-2\/","title":{"rendered":"High Fidelity detections are Low Fidelity detections, until proven otherwise, Part 2"},"content":{"rendered":"\n<p>In my <a href=\"https:\/\/www.hexacorn.com\/blog\/2024\/07\/14\/high-fidelity-detections-are-low-fidelity-detections-until-proven-otherwise\/\" data-type=\"post\" data-id=\"9279\">last post<\/a> I looked at &#8216;good&#8217; file names. Today I will look at them again. <\/p>\n\n\n\n<p>Sort of&#8230;<\/p>\n\n\n\n<p>Over the years I have written a number of yara rules that use a peculiar condition that hits on an internal PE file name sometimes being preserved inside some of the PE files, both DLL and EXE&#8230; If you ever looked at an internal structure of a PE file you know that its export directory has a capability to preserve a programmer-chosen, internal file name that is compiled into the final binary file, and that internal file name often differs from the file name being used on a file system level&#8230; <\/p>\n\n\n\n<p>Some Threat actors know about it and abuse it, but many don&#8217;t &#8211; in some cases allowing us to write very precise detection rules&#8230; That internal file name is a great forensic and telemetry artifact and it would be a crime not to use it, where applicable&#8230;<\/p>\n\n\n\n<p>In my old Yara rules I would usually rely on this (somehow) esoteric syntax that I copied and pasted from someone else (sorry, don&#8217;t remember who that person was):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">strings:\n   $dllname = \"&lt;filename&gt;\"\ncondition:\n   ($dllname at pe.rva_to_offset(uint32(pe.rva_to_offset(pe.data_directories [pe.IMAGE_DIRECTORY_ENTRY_EXPORT].virtual_address)+12)))<\/pre>\n\n\n\n<p>which is basically a rudimentary PE file format parsing condition checking if the specific ANSI string is present at a given place inside the file&#8217;s export directory (where that internal PE file name resides) and if it matches the string I defined&#8230;<\/p>\n\n\n\n<p>After the release of yara 4.0.0 we can use a far more simpler construct to define the very same condition &#8211; one that leverages the PE module:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pe.dll_name==\"&lt;filename&gt;\"<\/pre>\n\n\n\n<p>Now&#8230; <\/p>\n\n\n\n<p>This internal file name preserved in the export directory of many PE files is a bit of a phenomenon because if we just focus on native Windows OS binaries we will discover a lot of interesting bits. Say, we look at the native PE files taken from the Windows 11 system32 directory &#8212; we can easily discover a number of PE files where the &#8216;external&#8217; (file system-based) and &#8216;internal&#8217; (PE export directory-based\/pe.dll_name) file names do not match&#8230;<\/p>\n\n\n\n<p>Here&#8217;s a quick &amp; dirty <a href=\"https:\/\/hexacorn.com\/d\/internal_filenames.txt\" target=\"_blank\" rel=\"noreferrer noopener\">list<\/a> of such files that I&#8217;ve extracted&#8230;<\/p>\n\n\n\n<p>And just for a second, let me digress here &#8211; I must mention that I generated this quick&amp;dirty file for the purpose of writing this post but then&#8230; just eyeballing its content&#8230; my attention was immediately drawn to this interesting finding&#8230;:<\/p>\n\n\n\n<ul>\n<li>The Windows&#8217; library <em>AppVTerminator.dll<\/em> uses an internal file name of <em>Arnold.dll<\/em>. What&#8217;s more, the file exports a function called &#8216;IllBeBack&#8217;<\/li>\n<\/ul>\n\n\n\n<p>If you ever watched the 80\/90&#8217;s Terminator movie franchise you know this really cannot be a coincident, and a quick google session that followed led me to this <a href=\"https:\/\/gist.github.com\/EvanMcBroom\/ac2b9084bf3c84939efcb9c894fadd07\">gist<\/a> by <a href=\"https:\/\/twitter.com\/mcbroom_evan\">@mcbroom_evan<\/a>. I really love to be the first reporting OS-related interesting facts, peculiarities, and things that make you go &#8220;hmmm interesting&#8217;, but I was simply late in this case! Kudos to you <a href=\"https:\/\/twitter.com\/mcbroom_evan\">@mcbroom_evan<\/a>!<\/p>\n\n\n\n<p>Back to our quick &amp; dirty list&#8230;<\/p>\n\n\n\n<p>Looking at the internal file names used by many native Windows OS binaries we can immediately see a bit of a pattern:<\/p>\n\n\n\n<ul>\n<li>dll.dll 21<\/li>\n\n\n\n<li>deffile.dll 8<\/li>\n\n\n\n<li>stub.dll 7<\/li>\n\n\n\n<li>SWEEPRX.dll 3<\/li>\n\n\n\n<li>vm3ddevapi-release.exe 3<\/li>\n\n\n\n<li>vm3dum.dll 3<\/li>\n\n\n\n<li>vm3dum10.dll 3<\/li>\n\n\n\n<li>module.dll 3<\/li>\n\n\n\n<li>sb.dll 2<\/li>\n\n\n\n<li>iwb.dll 2<\/li>\n\n\n\n<li>USERCPL.dll 2<\/li>\n\n\n\n<li>smalldll.dll 2<\/li>\n\n\n\n<li>DeviceInfoParser.dll 2<\/li>\n\n\n\n<li>AppxDeploymentExtensions.dll 2<\/li>\n\n\n\n<li>inprocserver.dll 2<\/li>\n\n\n\n<li>winload.sys 2<\/li>\n\n\n\n<li>PACK2.dll 1<\/li>\n\n\n\n<li>Source.dll 1<\/li>\n\n\n\n<li>respub.DLL 1<\/li>\n\n\n\n<li>client.dll 1<\/li>\n<\/ul>\n\n\n\n<p>Seeing these stats we can speculate that lot of early code for these native system DLLs might have been created via a simple copy&amp;paste mechanism (<em>dll.dll<\/em>, <em>deffile.dll<\/em>, <em>smalldll.dll<\/em> and <em>stub.dll<\/em> are hardly unique file names&#8230;). Some discrepancies suggest internal struggles with terminology f.ex. <em>PrintIsolationProxy.dll<\/em> vs. <em>PrintSandboxProxy.dll<\/em> and some are completely off the limits (<em>tcblaunch.exe<\/em>\/<em>winload.exe<\/em> -> <em>winload.sys<\/em>). I&#8217;d like to believe there is a logic to it, but I am not very optimistic.<\/p>\n\n\n\n<p>Anyway&#8230;<\/p>\n\n\n\n<p>Now that we know what this post is all about, let&#8217;s take a stab at a far larger set&#8230; that is, legitimate files produced by legitimate vendors &#8211; many of their files do include these internal PE file names too, so it would be a crime not to explore this data set&#8230;<\/p>\n\n\n\n<p>So, here it is, <a href=\"https:\/\/hexacorn.com\/d\/_file_types_PE_INTERNAL_NAME.zip\">a list<\/a> of legitimate internal PE file names you may come across while analyzing samples. Using any of these &#8216;good&#8217; internal file names as a &#8216;<strong>pe.dll_name==&#8221;&lt;filename>&#8221;<\/strong>&#8216;  condition in your yara rules will most likely produce FPs&#8230; You have been warned \ud83d\ude42<\/p>\n\n\n\n<p>Note: you can\u2019t use the _file_types_PE_INTERNAL_NAME.zip\/_file_types_PE_INTERNAL_NAME files for commercial purposes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last post I looked at &#8216;good&#8217; file names. Today I will look at them again. Sort of&#8230; Over the years I have written a number of yara rules that use a peculiar condition that hits on an internal &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2024\/08\/01\/high-fidelity-detections-are-low-fidelity-detections-until-proven-otherwise-part-2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[53,39,19],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9314"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=9314"}],"version-history":[{"count":2,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9314\/revisions"}],"predecessor-version":[{"id":9318,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/9314\/revisions\/9318"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=9314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=9314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=9314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}