<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <title>OpenRCE: Blog</title>
        <link>http://www.openrce.org/rss/feeds/blog</link>
        <description>OpenRCE: The Open Reverse Code Engineering Community</description>
                <item>
            <title>Thanks Fravia! Rest In Peace</title>
                            <pubDate>Mon, 04 May 2009 20:32:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1440/Thanks_Fravia!_Rest_In_Peace</link>
                                        <author>ero &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Yesterday, May 3rd, the great &lt;a href=&quot;http://fravia.com/index.html&quot;&gt;Fravia&lt;/a&gt; &lt;a href=&quot;http://fravia.com/swansong.htm&quot;&gt;passed away&lt;/a&gt;. &lt;br /&gt;He ran his lengendary fravia pages and searchlores. A lot of people in the reverse engineering world are (and will be) definitely indebted to him for his teachings. He will definitely will be missed.&lt;br /&gt;&lt;br /&gt;Some friends notes on the sad news &lt;a href=&quot;http://sexy.pandas.es/blog/2009/05/04/ciao-maestro/&quot;&gt;here&lt;/a&gt;, &lt;a href=&quot;http://blog.48bits.com/?p=342&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://www.2113.ch/phplab/mbs.php3/mb001?num=1241367858&amp;thread=1241367858&quot;&gt;here&lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;http://blogger.googleusercontent.com/tracker/14788166-4719952483107898187?l=blog.dkbza.org&quot; /&gt;</description>
                    </item>
                <item>
            <title>More syscall ordinals</title>
                            <pubDate>Fri, 23 Jan 2009 18:44:00 -0600</pubDate>
                                        <link>https://www.openrce.org/blog/view/1345/More_syscall_ordinals</link>
                                        <author>ero &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Daniel Reynaud has improved on the script I &lt;a&gt;described&lt;/a&gt; a while ago and &lt;a href=&quot;http://indefinitestudies.org/2009/01/22/digging-up-system-calls-ordinals-on-xp-x64/&quot;&gt;has posted&lt;/a&gt; on &lt;a href=&quot;http://indefinitestudies.org/&quot;&gt;his blog&lt;/a&gt; the system call ordinals for Windows XP SP2 x64.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;http://blogger.googleusercontent.com/tracker/14788166-3750137076564516747?l=blog.dkbza.org&quot; /&gt;</description>
                    </item>
                <item>
            <title>pefile and LOAD_CONFIG</title>
                            <pubDate>Fri, 23 Jan 2009 01:58:00 -0600</pubDate>
                                        <link>https://www.openrce.org/blog/view/1346/pefile_and_LOAD_CONFIG</link>
                                        <author>ero &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Following a conversation in twitter Ive noticed &lt;a href=&quot;http://code.google.com/p/pefile/ &quot;&gt;pefile&lt;/a&gt; was lacking support for parsing one data directory in the PE format that is rather interesting, the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms680328(VS.85).aspx&quot;&gt;IMAGE_LOAD_CONFIG_DIRECTORY&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Ive added support for it and fixed a few small bugs and released it as &lt;a href=&quot;http://code.google.com/p/pefile/downloads/list&quot;&gt;pefile-1.2.10-60&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now one can access this structures fields like, for instance, pe.DIRECTORY_ENTRY_LOAD_CONFIG.struct.SecurityCookie or pe.DIRECTORY_ENTRY_LOAD_CONFIG.struct.SEHandlerTable and also modify their values and write the result to a new PE file, all the usual handling &amp; mangling that pefile allows.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;http://blogger.googleusercontent.com/tracker/14788166-2723490943804140660?l=blog.dkbza.org&quot; /&gt;</description>
                    </item>
                <item>
            <title>Tips and tricks</title>
                            <pubDate>Thu, 08 Jan 2009 17:39:00 -0600</pubDate>
                                        <link>https://www.openrce.org/blog/view/1347/Tips_and_tricks</link>
                                        <author>ero &lt;email-suppressed@example.com&gt;</author>
                                                    <description>A couple of interesting things Ive found out lately:&lt;br /&gt;&lt;br /&gt;When packaging the latest &lt;a href=&quot;http://code.google.com/p/pefile/&quot;&gt;pefile&lt;/a&gt; I noticed the dot-underscore files in the tar.gz.&amp;nbsp;&amp;nbsp;If one extracts the contents there are no such files to be found (if youre working on OSX) while they will show up in other operating systems. Those dot-underscore files are OSX way of storing the &lt;a href=&quot;http://en.wikipedia.org/wiki/Resource_fork&quot;&gt;resource fork&lt;/a&gt; (metainformaion). While it might be handy to keep it around when moving files between Macs, its not nice to have such dot-underscore files show up in other systems. How to get rid of them is not too well documented. &lt;br /&gt;&lt;br /&gt;There are two oddly named environment variables (they changed between OSX versions) that control the creation of such files. Setting the following envionment variables to true will make &lt;i&gt;tar&lt;/i&gt; not create those dot-underscore files when archiving a file with a resource fork.&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;COPYFILE_DISABLE&lt;br /&gt;COPY_EXTENDED_ATTRIBUTES_DISABLE&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;One can just set them in the python setup.py script, so when the source distribution is created, no resource forks are dumped into those files.&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;import os&lt;br /&gt;os.environ[COPY_EXTENDED_ATTRIBUTES_DISABLE] = true&lt;br /&gt;os.environ[COPYFILE_DISABLE] = true&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;In my case it was &lt;a href=&quot;http://macromates.com/&quot;&gt;TextMate&lt;/a&gt; that was using a resource fork to store some metainformation about the Python files I was working with.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now a useful tip for &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;subversion&lt;/a&gt;. I always knew CVS and subversion had to have such feature but never was able to find how to use, I finally tracked it down.&lt;br /&gt;&lt;br /&gt;This might not be knew to anyone that has spent some time with svn... but was to me. The things is, I was sure there had to be a comfortable way of having SVN automatically add the revision number to the source code. That would allow to have version numbers with a revision appended to them automatically, which would make lots of things much nicer, like tracking errors with specific versions.&lt;br /&gt;&lt;br /&gt;To achieve that, one can use &lt;a href=&quot;http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html&quot;&gt;subversion keywords&lt;/a&gt;. SVN will replace those keywords with the appropriate information. In this case the cool one is &quot;$LastChangedRevision$&quot;, whereever we write it, it will get replaced by &quot;$LastChangedRevision: XXX $&quot; where XXX is the revision number.&lt;br /&gt;&lt;br /&gt;You need to tell subversion you want it to replace that keyword in a given file(s). To do that just issue a: &lt;i&gt;svn propset svn:keywords &quot;Rev&quot; path/to/the/file&lt;/i&gt; to set the property on that file.&lt;br /&gt;&lt;br /&gt;A practical example for Python code would be:&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;__revision__ = &quot;$LastChangedRevision$&quot;&lt;br /&gt;__version__ = %d % int( __revision__[21:-2] )&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;The keyword would be replaced as described above and then we can fetch the revision number and add it to the version number transparently. Subversion will handle it cleanly.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;http://blogger.googleusercontent.com/tracker/14788166-2457796022368917555?l=blog.dkbza.org&quot; /&gt;</description>
                    </item>
                <item>
            <title>Thoughts on &quot;Using dual-mappings to evade automated unpackers&quot;</title>
                            <pubDate>Tue, 21 Oct 2008 15:29:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1290/Thoughts_on_"Using_dual-mappings_to_evade_automated_unpackers"</link>
                                        <author>ero &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;a href=&quot;http://www.uninformed.org/?v=10&quot;&gt;Uninformed 10&lt;/a&gt; was released recently. On it Skape brings about a simple, yet beautiful and powerful idea. The &lt;a href=&quot;http://www.uninformed.org/?v=10&amp;a=1&quot;&gt;paper itself&lt;/a&gt; is short and concise but a quick summary would be along the lines of: some generic unpackers use, either as their main technique or as an heuristic, the tracking of memory writes and whenever the execution flow hits those written areas an&amp;nbsp;&amp;nbsp;assumption is made that unpacked (or self-modifying code) has been reached. This is an over-simplification because of multi-staged unpackers and other details, but will suffice for the sake of the discussion. Skape basically introduces a technique by which hes able to write into a range of virtual addresses an execute from another range, both pointing to the same real data.&lt;br /&gt;&lt;br /&gt;This is a well supported technique and nothing strange of itself. It is its use what is creative and rather amusing as it breaks the assumption mentioned earlier. Given that no writes are seen in the area of memory that will be executed. The technique relies on the possibility of having several virtual addresses refer the same physical memory. The &lt;a href=&quot;http://en.wikipedia.org/wiki/Memory_management_unit&quot;&gt;Memory Management Unit (MMU)&lt;/a&gt; allows pages of virtual memory to map to common physical locations in order to avoid, for instance, the need of having multiple copies of shared components between different processes.&lt;br /&gt;&lt;br /&gt;Some of the tools having trouble with this trick cant really do much about it but other tools he mentions in the paper should have no issue handling it in some way or another.&lt;br /&gt;&lt;br /&gt;Ive been working with Bochs for a few years. The technique should be (and is) easily defeatable by tools providing a birds eye perspective like &lt;a href=&quot;http://bochs.sourceforge.net/&quot;&gt;Bochs&lt;/a&gt; or by tools running in kernel mode.&lt;br /&gt;&lt;br /&gt;Analyzing the generally one-to-one mapping of virtual-to-physical memory to find a one-to-many relationship is not all that difficult, and the case where a set of virtually mapped pages receive writes and not much more and another set pointing to the same physical ranges is only (or mostly just) executed should be easy to determine. Thatd be a simple heuristic but attempting to defeat it by writing to the execute-only mapping would break down the whole idea...&lt;br /&gt;&lt;br /&gt;Its definitely a beatiful idea but its easy to detect if youre on the right spot. &lt;br /&gt;&lt;br /&gt;One can take a quick look at it if you have &lt;a href=&quot;http://en.wikipedia.org/wiki/WinDbg&quot;&gt;Windbg&lt;/a&gt; lying around. Just connect to your test machine running a test process that implements the code that Skape outlines.&lt;br /&gt;&lt;br /&gt;Do a quick process listing to find it by issuing:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;!process 0 0&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Then, take a look at the &lt;b&gt;Cid&lt;/b&gt; of the process of interest and get its details with:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;!process &amp;lt;Cid&amp;gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;In that listing the page directory base &lt;b&gt;DirBase&lt;/b&gt; will be given. With that we can tell Windbg to do the mapping of a virtual address using the virtual-to-physical mapping of that process by pasing the directory base to the &lt;b&gt;!vtop&lt;/b&gt; command. In my case the &lt;b&gt;DirBase&lt;/b&gt; of my process was &lt;i&gt;f5a&lt;/i&gt; and Ill instruct Windbg to give me the corresponding physical address to which the virtual addresses 0x419000 and 0x519000 are mapped (those addresses are specific to the example code I wrote implementing skapes idea)&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;lkd&gt; !vtop f5a 0x419000&lt;br /&gt;Pdi 1 Pti 19&lt;br /&gt;00419000 14a79000 pfn(14a79)&lt;br /&gt;lkd&gt; !vtop f5a 0x519000&lt;br /&gt;Pdi 1 Pti 119&lt;br /&gt;00519000 14a79000 pfn(14a79)&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;As you can see both lead to the same physical location &lt;i&gt; 14a79000&lt;/i&gt;. So its easy to see this from kernel mode by walking the page directory of a process under surveillance. &lt;br /&gt;&lt;br /&gt;If you want to see all physical-virtual mappings the following command provides that:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;!ptov f5a&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Ive also implemented detection of this trick in some Python scripts Ive developed for my Python-weaponized Bochs environment. &lt;i&gt;On that front. I have an up-to-date patch for Bochs (improved from what I introduced at HitB in Dubai). While I hope to be able to eventually work with the Bochs developers to merge it anyone that wants to give it a shot it welcome to shoot me an email... &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Ill be talking on packers and their techniques on the forthcoming &lt;a href=&quot;http://conference.hackinthebox.org/hitbsecconf2008kl/&quot;&gt;Hack in the Box&lt;/a&gt; in Kuala Lumpur. Ill be there next week and later in November at &lt;a href=&quot;http://www.powerofcommunity.net/home.html&quot;&gt;Power Of Community&lt;/a&gt; in Korea.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;http://blogger.googleusercontent.com/tracker/14788166-7675451166227376539?l=blog.dkbza.org&quot; /&gt;</description>
                    </item>
            </channel>
</rss>
