{"id":6059,"date":"2019-03-14T00:15:52","date_gmt":"2019-03-14T00:15:52","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=6059"},"modified":"2019-03-14T00:15:53","modified_gmt":"2019-03-14T00:15:53","slug":"pe-files-and-the-demoscene","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2019\/03\/14\/pe-files-and-the-demoscene\/","title":{"rendered":"PE files and the DemoScene"},"content":{"rendered":"\n<p>One of the most creative ways of constructing PE files come not from malware authors, but from so-called <a href=\"https:\/\/en.wikipedia.org\/wiki\/Demoscene\">DemoScene<\/a>. Squeezing in everything possible in the smallest possible file is a form of an art. It has roots in competitions that forced the participants to use very restrictive environment to produce the best demo effect possible. From a file format perspective, this resulted in many cool productions where the PE file structure looks completely non-sensical, almost like non-PE, yet when executed, still produces some sort of demo effect.<\/p>\n\n\n\n<p>See for yourself. Is this a valid PE file?<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"654\" height=\"203\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/03\/pe_demoscene1.png\" alt=\"\" class=\"wp-image-6060\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/03\/pe_demoscene1.png 654w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/03\/pe_demoscene1-300x93.png 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/figure>\n\n\n\n<p>There is no visible DOS Stub, no strings, no library names, no API names, it looks like an old DOS MZ file. At least at a first glance.<\/p>\n\n\n\n<p>It <a href=\"http:\/\/ftp.scene.org\/pub\/demos\/artists\/0rel\/brnd.zip\">actually<\/a> is a PE file though.<\/p>\n\n\n\n<p>Many PE Editors, Viewers, and Dumpers have a serious problem analyzing this sort of files, because they can&#8217;t handle exceptions that happen during processing. They are typically triggered by some of the PE header structure fields being re-used by demos to store actual code\/data for the presentation (no byte is wasted). These values tend to be random, and definitely outside of the boundaries of a file, or image in memory. Operating system loader ignores many of such out-of-bound indexes, while PE tools tend to &#8216;trust&#8217; the content, and interpret them as valid values, and&#8230; eventually fail.<\/p>\n\n\n\n<p>I won&#8217;t be naming names, but can confirm that among a couple of tools that I tested, some failed to load this file, some didn&#8217;t show proper code from the entry point, because they miscalculated the offset where the code is located.  <\/p>\n\n\n\n<p>Overall, it&#8217;s good to test your parsers by including such PE curiosities in your test bed (Scene.org is a great source for these, but don&#8217;t forget Corkami repo &#8211; Ange took the art of hand crafted PEs to a completely new level).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most creative ways of constructing PE files come not from malware authors, but from so-called DemoScene. Squeezing in everything possible in the smallest possible file is a form of an art. It has roots in competitions that &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/03\/14\/pe-files-and-the-demoscene\/\">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":[13,21],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6059"}],"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=6059"}],"version-history":[{"count":3,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6059\/revisions"}],"predecessor-version":[{"id":6063,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6059\/revisions\/6063"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=6059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=6059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=6059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}