{"id":5935,"date":"2019-02-13T01:27:57","date_gmt":"2019-02-13T01:27:57","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=5935"},"modified":"2019-02-13T11:24:04","modified_gmt":"2019-02-13T11:24:04","slug":"pe-files-and-the-easy-programming-language-epl","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2019\/02\/13\/pe-files-and-the-easy-programming-language-epl\/","title":{"rendered":"PE files and the Easy Programming Language (EPL)"},"content":{"rendered":"\n<p>If you ever came across portable executables that include references to enigmatic modules called: <\/p>\n\n\n\n<ul><li>krnln.fne<\/li><li>krnln.fnr<\/li><li>eAPI.fne<\/li><li>RegEx.fnr <\/li><\/ul>\n\n\n\n<p>and many other libraries with a <em>.fne<\/em>, or <em>.fnr<\/em> file extensions, or perhaps found some of these files during a forensic exam, then this post is for you.<\/p>\n\n\n\n<p>These executables are generated by so-called Easy Programming Language (EPL), a RAD, Visual Basic-like programming language and software development environment available from this <a href=\"http:\/\/epl.eyuyan.com\/\">Chinese<\/a> company, and also available from this <a href=\"http:\/\/www.dywt.com.cn\">website<\/a>. It&#8217;s not super popular, but it definitely has a following in China as programs are still being written in it. Including malware.<\/p>\n\n\n\n<p>If you are in a hurry, you can download and play with the actual RAD v 4.01 from <a href=\"http:\/\/edata.eyuyan.com\/edown\/EPL\/een_ins.exe\">here<\/a> or <a href=\"http:\/\/edata.eyuyan.com\/edown\/EPL\/een_ins.exe\">here<\/a>.<\/p>\n\n\n\n<p>When you install it, you will quickly notice that it populates c:\\Program Files\\EPL\\lib folder with all these familiar libraries:<\/p>\n\n\n\n<p><em>btdownload.fne, cncnv.fne, com.run, cominf.run, downlib.fne, dp1.fne, eAPI.fne, eCalc.fne, EChartBar.fne, eCompress.fne, EDataStructure.fne, eDB.fne, edroptarget.fne, eExcel2000.fne, eGrid.fne, eImgConverter.fne, EInterProcess.fne, eMMedia.fne, eNetIntercept.fne, ePPT2000.fne, ERawSock.fne, ESpeechEngine.fne, ESPI11.dll, ESSLayer.fne, EThread.fne, ewizard.fne, eWord2000.fne, EXMLParser.fne, Exmlrpc.fne, ExtMenu.fne, HtmlView.fne, iext.fne, iext.fnr, iext2.fne, iext3.fne, internet.fne, isapi.fne, Javalib.fne, krnln.fne, krnln.fnr, mp3.run, mysql.fne, ocx.run, odbcdb.run, OPenGL.fne, PhoneCortrol.fne, pop3.fne, portio.fne, RegEx.fne, script.fne, shell.fne, sock.fne, spec.fne, twain.fne, Warning.txt, WNet.fne, xplib.fne<\/em><\/p>\n\n\n\n<p>Since the user interface is in English, we can easily load one of the samples provided with the framework e.g. Funny Ball Game:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl1.png\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl1.png\" alt=\"\" class=\"wp-image-5936\" width=\"500\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl1.png 827w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl1-300x185.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl1-768x474.png 768w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl1-80x50.png 80w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><\/a><\/figure>\n\n\n\n<p>We can then compile the game and run it:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl2.png\" alt=\"\" class=\"wp-image-5938\" width=\"389\" height=\"368\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl2.png 546w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl2-300x284.png 300w\" sizes=\"(max-width: 389px) 100vw, 389px\" \/><\/a><\/figure>\n\n\n\n<p>Now that we compiled and ran the executable, we can look at the file itself. <\/p>\n\n\n\n<p>While the framework requires you to register before you can build the standalone programs, it still provides a way to compile &amp; test them. For the test purposes it provides a small stub executable that launches programs, and does so from a Temporary directory. The commercial version allows to package it all into one standalone .exe. It&#8217;s the &#8216;packaged&#8217; version of .exe we will typically come across &#8216;in the wild&#8217;.<\/p>\n\n\n\n<p>Looking at the stub .exe:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl3.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl3.png\" alt=\"\" class=\"wp-image-5940\" width=\"281\" height=\"360\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl3.png 500w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl3-234x300.png 234w\" sizes=\"(max-width: 281px) 100vw, 281px\" \/><\/a><\/figure>\n\n\n\n<p>we can notice the following strings of interest:<\/p>\n\n\n\n<ul><li>krnln.fne<\/li><li>GetNewSock<\/li><li>Software\\FlySky\\E\\Install<\/li><li>Not found the kernel library or the kernel library is invalid!<\/li><li>Failed to allocate memory!<\/li><li>\/ MADE BY E COMPILER &#8211; WUTAO <\/li><\/ul>\n\n\n\n<p>Looking at the PE file properties, we can see that the stub is pretty old:<\/p>\n\n\n\n<ul><li>TimeDateStamp: 0x3925136B (GMT: Fri May 19 10:11:55 2000)<\/li><\/ul>\n\n\n\n<p>I am not sure if this timestamp is good enough for any identification as I don&#8217;t have enough samples. Plus, this is a stub used for testing. Still, it could be used to run actual E programs (you can find some on github and elsewhere).<\/p>\n\n\n\n<p>The easiest way to identify the program compiled with EPL is to look at its sections:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"486\" height=\"161\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl4-1.png\" alt=\"\" class=\"wp-image-5954\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl4-1.png 486w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl4-1-300x99.png 300w\" sizes=\"(max-width: 486px) 100vw, 486px\" \/><\/figure>\n\n\n\n<p>The <em>.ecode<\/em> section name is very characteristic, and I have added it to my <a href=\"https:\/\/www.hexacorn.com\/blog\/2016\/12\/15\/pe-section-names-re-visited\/\">PE Section list<\/a>; you may also come across <em>.edata<\/em> section; this, together with a list of strings, and modules listed earlier (and probably a few more than can be found online &#8211; one can create new ones) should be enough to ID the files (e.g. via Yara).<\/p>\n\n\n\n<p>Since the file format is quite obscure, and programs&#8217; dynamic analysis not well researched, many AV and sandbox vendors list some of the artifacts created by the EPL framework as malicious, <em>just because it&#8217;s there<\/em>, for instance this Registry key entry:<\/p>\n\n\n\n<ul><li>HKCU\\Software\\FlySky\\E\\Install\\Path<\/li><\/ul>\n\n\n\n<p>It actually points to a location where the clean libraries are; on a system where the development environment is installed it points to:<\/p>\n\n\n\n<ul><li>C:\\Program Files\\EPL\\lib\\<\/li><\/ul>\n\n\n\n<p>In cases where the .exe is standalone, when the program is executed the libraries are automatically unpacked to a temporary folder e.g.:<\/p>\n\n\n\n<ul><li>%Temp%\\E_4<\/li><li>%Temp%\\E_N4<\/li><\/ul>\n\n\n\n<p>The registry entry will be then pointed to that directory. This is obviously a possible persistence mechanism, but its value is pretty low for today&#8217;s standard&#8230;<\/p>\n\n\n\n<p>During the development phase programs are stored in files with a <em>.e<\/em> file extension. Some programmers distribute them in this form as well (again, that&#8217;s what you can find on github and elsewhere!).<\/p>\n\n\n\n<p>Looking at a sample <em>.e<\/em> file and its top few bytes we can see a magic string  &#8216;CNWTEPRG&#8217;:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl5.png\"><img decoding=\"async\" loading=\"lazy\" width=\"654\" height=\"167\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl5.png\" alt=\"\" class=\"wp-image-5944\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl5.png 654w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl5-300x77.png 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/a><\/figure>\n\n\n\n<p>References to a <em>MainForm<\/em> string, and top bytes (<em>BM<\/em>) of a of a bitmap (.bmp) file are clearly visible. The graphic files can be carved out easily from a <em>.e<\/em> file. Plus, we can always load the file into the actual developer environment to see what the source code it holds. <\/p>\n\n\n\n<p>For the sample game I have shown earlier, we can double click the form and end up in a code window shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl7.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl7.png\" alt=\"\" class=\"wp-image-5948\" width=\"400\" height=\"395\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl7.png 797w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl7-300x297.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl7-768x759.png 768w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/figure>\n\n\n\n<p>Looking for existing tools that can understand the internal file format of PE files generated by the EPL (especially the packaged ones), I came across a very old Chinese tool called E-Code Explorer. You can download it from <a href=\"https:\/\/translate.google.com\/translate?hl=en&amp;sl=zh-CN&amp;tl=en&amp;u=https%3A%2F%2Fweb.archive.org%2Fweb%2F20070403033842%2Fhttp%3A%2F%2Fmonkeycz.pediy.com%2F\">here<\/a> (Web Archive copy over Google Translate :)). Since the  E-Code Explorer interface is in Chinese, it&#8217;s a bit tricky to operate (screenshot below is from <a href=\"https:\/\/web.archive.org\/web\/20070104040242\/http:\/\/monkeycz.pediy.com\/test.jpg\">here<\/a>):<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl6.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl6-1024x768.jpg\" alt=\"\" class=\"wp-image-5946\" width=\"404\" height=\"302\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl6.jpg 1024w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl6-300x225.jpg 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl6-768x576.jpg 768w\" sizes=\"(max-width: 404px) 100vw, 404px\" \/><\/a><\/figure>\n\n\n\n<p>Looking for a good candidate .exe file that could be open with this tool I checked the actual development environment. Not surprisingly, it&#8217;s also (at least partially!) written in EPL! After poking around I found out that c:\\Program Files\\EPL\\setup\\mksetup.exe can be loaded without any issues:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl9.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl9.png\" alt=\"\" class=\"wp-image-5950\" width=\"422\" height=\"227\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl9.png 609w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl9-300x162.png 300w\" sizes=\"(max-width: 422px) 100vw, 422px\" \/><\/a><\/figure>\n\n\n\n<p>The program reads the internal structures of the .exe, recognizes its e-code signature, and version. It also lists a lot of information in a way similar to other tools do so for other frameworks, e.g. lists e-code modules the program relies on: <\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epla.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epla.png\" alt=\"\" class=\"wp-image-5951\" width=\"428\" height=\"161\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epla.png 857w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epla-300x113.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epla-768x290.png 768w\" sizes=\"(max-width: 428px) 100vw, 428px\" \/><\/a><\/figure>\n\n\n\n<p>and calculates offsets for internal sections:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/eplb.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"271\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/eplb-1024x271.png\" alt=\"\" class=\"wp-image-5952\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/eplb-1024x271.png 1024w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/eplb-300x80.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/eplb-768x204.png 768w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/eplb.png 1079w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>This, and a traditional tree-like browser (shown below) may come handy during malware analysis:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl8.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl8.png\" alt=\"\" class=\"wp-image-5949\" width=\"392\" height=\"610\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl8.png 574w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/02\/epl8-192x300.png 192w\" sizes=\"(max-width: 392px) 100vw, 392px\" \/><\/a><\/figure>\n\n\n\n<p>Also, when I looked at this file format a few years ago I recall seeing actual description of the internal structures of the standalone .exes, but can&#8217;t find it at the moment.<\/p>\n\n\n\n<p>I guess this file format is more a curiosity than anything else, but yet another PE file type to be aware of. What&#8217;s more, I am aware of tools written in EPL actually being found during forensic investigations so you may actually come across the .fne, .fnr files during your exams&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you ever came across portable executables that include references to enigmatic modules called: krnln.fne krnln.fnr eAPI.fne RegEx.fnr and many other libraries with a .fne, or .fnr file extensions, or perhaps found some of these files during a forensic exam, &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/02\/13\/pe-files-and-the-easy-programming-language-epl\/\">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":[21,19,9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/5935"}],"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=5935"}],"version-history":[{"count":13,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/5935\/revisions"}],"predecessor-version":[{"id":5966,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/5935\/revisions\/5966"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=5935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=5935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=5935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}