{"id":7134,"date":"2020-04-24T22:38:24","date_gmt":"2020-04-24T22:38:24","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=7134"},"modified":"2020-04-24T22:38:26","modified_gmt":"2020-04-24T22:38:26","slug":"re-sauce-part-1","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2020\/04\/24\/re-sauce-part-1\/","title":{"rendered":"Re-sauce, Part 1"},"content":{"rendered":"\n<p>PE Resources are like an unwanted child of malware analysis and reverse engineering. Almost no one talks about them and&#8230; this post is going to&#8230; make it worse ;).<\/p>\n\n\n\n<p>Let&#8217;s take a large number of &#8216;bad&#8217; samples, export their resource information, and do some data crunching&#8230; we now have some stats.<\/p>\n\n\n\n<p>What are the most popular resources?<\/p>\n\n\n\n<p>These are:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>4720830   RT_ICON (3) -\n4703093   RT_GROUP_ICON (14) -\n3445748   RT_VERSION (16) -\n2574034   RT_MANIFEST (24) -\n2291058   RT_DIALOG (5) -\n2022739   RT_STRING (6) -\n1564623   RT_RCDATA (10) -\n1193659   RT_BITMAP (2) -\n1159726    'DVCLAL' -\n1050941    'PACKAGEINFO' -\n 931572    'MAINICON' -\n 903265   RT_CURSOR (1) -\n 884868   RT_GROUP_CURSOR (12) -\n 557473    'BBABORT' -\n 551898    'BBALL' -\n 551836    'BBOK' -\n 551785    'BBNO' -\n 551023    'BBRETRY' -\n 542886    'BBIGNORE' -\n 542836    'BBHELP' -\n 542834    'BBCLOSE' -\n 542593    'BBYES' -\n 541708    'BBCANCEL' -\n 498816    'PREVIEWGLYPH' -\n 497272    'DLGTEMPLATE' -\n 358081   RT_MENU (4) -\n 199615    'TFORM1' -\n 174781   RT_ACCELERATOR (9) -\n<\/code><\/pre>\n\n\n\n<p>These with a RT_prefix are standard resource types <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/menurc\/resource-types\">defined<\/a> by Microsoft, and the ones in apostrophes are strings that &#8216;tag&#8217; (or &#8216;name&#8217;) the resources according to developer&#8217;s wishes&#8230; <\/p>\n\n\n\n<p>Given a number of these &#8216;named&#8217; ones used repeatedly (as shown by the list above) you can guess that they are somehow &#8216;known&#8217;, or a part of some &#8216;standard&#8217; &#8212; and yup, these are primarily from Borland\/Delphi\/Embarcadero family of executables that include standard GUI elements from this platform. All &#8216;BB*&#8217; and &#8216;T*&#8217; come from this environment. Additionally &#8216;PACKAGEINFO&#8217; is a resource I covered a little bit in the <a href=\"https:\/\/www.hexacorn.com\/blog\/2012\/07\/02\/random-stats-from-300k-malicious-samples-borland-libraries\/\">past<\/a> &#8211; it lists all the packages the executable uses (a good IOC except no one writes malware in Delphi anymore).<\/p>\n\n\n\n<p>Surprisingly, modern PE Viewers and Editors do not parse PE resources very well. They only show the most popular resource types, because the others are often &#8230; undocumented. I really don&#8217;t like to look at resources in hex view. We can do better.<\/p>\n\n\n\n<p>Let&#8217;s start with these that are &#8216;kinda documented&#8217;. <\/p>\n\n\n\n<p>For instance, Resource Hacker can handle some Delphi resources (e.g. forms) pretty well:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_1.png\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_1.png\" alt=\"\" class=\"wp-image-7135\" width=\"350\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_1.png 518w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_1-212x300.png 212w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/a><\/figure>\n\n\n\n<p>A popular &#8216;Typelib&#8217; resource:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_2.png\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_2.png\" alt=\"\" class=\"wp-image-7136\" width=\"500\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_2.png 808w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_2-300x124.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_2-768x317.png 768w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>can be viewed with OleView:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_3.png\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_3.png\" alt=\"\" class=\"wp-image-7137\" width=\"500\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_3.png 928w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_3-300x94.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/res_3-768x240.png 768w\" sizes=\"(max-width: 928px) 100vw, 928px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>The &#8216;Registry&#8217; is typically an embedded &#8216;.reg&#8217; file.<\/p>\n\n\n\n<p>A &#8216;FOMB&#8217; is a binary MOF that was described in <a href=\"https:\/\/www.fireeye.com\/blog\/threat-research\/2019\/10\/certutil-qualms-they-came-to-drop-fombs.html\">this post<\/a> by FireEye and can be decoded using <a href=\"https:\/\/github.com\/pali\/bmfdec\">bmfdec<\/a>.<\/p>\n\n\n\n<p>What about the others?<\/p>\n\n\n\n<p>And this is where it gets really difficult&#8230;<\/p>\n\n\n\n<p>Looking at resources embedded in Windows 10 exe, dll, ocx files one can very quickly build a list of more or less enigmatically-looking resource names:<\/p>\n\n\n\n<ul><li>ACCELERATOR<\/li><li>ANICURSOR<\/li><li>AVI<\/li><li>BINARY<\/li><li>BITMAP<\/li><li>BITMAP4<\/li><li>BRANDING_METADATA_RES<\/li><li>BRANDING_REQUIRED_RESOURCEID_MAP<\/li><li>CERT<\/li><li>CODEPAGES<\/li><li>CODEPAGESEXT<\/li><li>CURSOR<\/li><li>DATA_FILE<\/li><li>DATAFILERESOURCE<\/li><li>DGML<\/li><li>DIALOG<\/li><li>DUI<\/li><li>EDPAUTOPROTECTIONALLOWEDAPPINFOID<\/li><li>EDPENLIGHTENEDAPPINFOID<\/li><li>EDPPERMISSIVEAPPINFOID<\/li><li>EMBEDDEDDATA<\/li><li>FILES<\/li><li>FLEX_TABLE<\/li><li>FLEXDL<\/li><li>FONT<\/li><li>FONTDIR<\/li><li>FONTFALLBACK<\/li><li>GIF<\/li><li>GROUP_CURSOR<\/li><li>GROUP_ICON<\/li><li>HTML<\/li><li>HWB<\/li><li>HWXLANGID<\/li><li>IBC<\/li><li>ICON<\/li><li>IMAGE<\/li><li>JPEG<\/li><li>JS<\/li><li>JSON<\/li><li>JSON_RESPONSE<\/li><li>MANIFEST<\/li><li>MENU<\/li><li>MESSAGETABLE<\/li><li>MOFDATA<\/li><li>MSTESTROOT<\/li><li>MUI<\/li><li>PNG<\/li><li>PNGFILE<\/li><li>PRELOAD<\/li><li>PRXFILE<\/li><li>RCDATA<\/li><li>REGINST<\/li><li>REGISTRY<\/li><li>RGSLIST<\/li><li>SCHEMA<\/li><li>SIAMDB<\/li><li>SKDFILE<\/li><li>SRGRAMMAR<\/li><li>STYLE_XML<\/li><li>TESTROOT<\/li><li>TEXT<\/li><li>TEXTINCLUDE<\/li><li>TUNINGSPACE<\/li><li>TYPELIB<\/li><li>UIFILE<\/li><li>VR_ETW_MANIFEST<\/li><li>VR_ETW_RESOURCE<\/li><li>VSGEXP<\/li><li>WAVE<\/li><li>WEVT_TEMPLATE<\/li><li>XML<\/li><li>XML_FILE<\/li><li>XML_SCHEMA<\/li><li>XMLFILE<\/li><li>XSD<\/li><li>XSDFILE<\/li><li>XSLFILE<\/li><\/ul>\n\n\n\n<p>Yup. Some are easy to handle (just by looking at their name e.g. AVI, BITMAP, XML), but&#8230; this is just Windows 10. <\/p>\n\n\n\n<p>Time will tell if we will ever see a PE editor\/viewer that can handle all of, or at least most of these well.<\/p>\n\n\n\n<p>In the meantime&#8230;<\/p>\n\n\n\n<p>Resources is something you may want to look at more closely. Starting today.<\/p>\n\n\n\n<p>Why?<\/p>\n\n\n\n<p>Because of this guy:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"170\" height=\"169\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/norton.png\" alt=\"\" class=\"wp-image-7140\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/norton.png 170w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/04\/norton-150x150.png 150w\" sizes=\"(max-width: 170px) 100vw, 170px\" \/><\/figure>\n\n\n\n<p>I got it from resources of Norton SecureWorks circa 2002-2003. Do you even remember this software existed?<\/p>\n\n\n\n<p>One of cool side-effects of poking around in many resources is coming across weird, unusual strings, texts, images, movies, you name it. You will find developer pictures that were not meant for general public, &#8216;tagging&#8217; images with names of developers of project managers, jokes, and whatever else. Yes, there is cheezy, there is porn, there are obscenities, there are also Easter Eggs. <\/p>\n\n\n\n<p>If you want to start building your own collection, it couldn&#8217;t be easier&#8230;<\/p>\n\n\n\n<p>You can simply use:<\/p>\n\n\n\n<ul><li>7z l &lt;filename> .rsrc <ul><li>to list all the resources of a &lt;filename> <\/li><\/ul><\/li><li>7z x &lt;filename> .rsrc&#8217; <ul><li>to extract them.<\/li><\/ul><\/li><\/ul>\n\n\n\n<p>And then start data crunching:<\/p>\n\n\n\n<ul><li>Icons are interesting, especially if re-used for malicious purposes (e.g. Adobe, Microsoft) &#8211;> there are existing yara sigs for these!<\/li><li>Manifest may include references to other executables\/DLLs loaded<\/li><li>Manifest may also include references to rights required for running the executable (e.g. look for level=&#8221;requireAdministrator&#8221;)<\/li><li>Language information may be helpful with attribution (beware of false flags)<\/li><li>Version Information lists lots of interesting information that can be co-related with the information extracted from certificates \/ signatures, if present<\/li><li>Delphi resources are fairly well documented and can be extracted, especially the aforementioned package names &#8212; can help to at least cluster samples as per the modules used (may sometimes highlight similar families, plus good for yara sigs)<\/li><li>Everything else should be extracted and checked against typical file types\/magic:<ul><li>BMP<\/li><li>PNG<\/li><li>GIF<\/li><li>JPG<\/li><li>AVI<\/li><li>Wav<\/li><li>Rtf<\/li><li>Ico<\/li><li>Cur<\/li><li>PE files<\/li><li>LE files (older version of MZ executables)<\/li><li>MZ files (yup, plain DOS)<\/li><li>UTF8\/Unicode BOMs<\/li><li>Office files<\/li><li>etc.<\/li><\/ul><\/li><\/ul>\n\n\n\n<p>Resources are a very important metadata source for analysts. If you are lucky you may not only get the visuals, but also timestamps (e.g. in <a href=\"https:\/\/www.hexacorn.com\/blog\/2014\/12\/05\/the-not-so-boring-land-of-borland-executables-part-1\/\">Delphi executables<\/a>).<\/p>\n\n\n\n<p>Be err&#8230; resourceful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PE Resources are like an unwanted child of malware analysis and reverse engineering. Almost no one talks about them and&#8230; this post is going to&#8230; make it worse ;). Let&#8217;s take a large number of &#8216;bad&#8217; samples, export their resource &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2020\/04\/24\/re-sauce-part-1\/\">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,21,19],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7134"}],"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=7134"}],"version-history":[{"count":5,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7134\/revisions"}],"predecessor-version":[{"id":7143,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7134\/revisions\/7143"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=7134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=7134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=7134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}