<?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>BlackHat Europe</title>
                            <pubDate>Thu, 27 Mar 2008 15:15:41 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1093/BlackHat_Europe</link>
                                        <author>pedram &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;a href=&quot;http://blog.dkbza.org&quot;&gt;Ero&lt;/a&gt; and I finished up our two day &lt;a href=&quot;http://www.blackhat.com/html/bh-europe-08/train-bh-eu-08-pa.html&quot;&gt;Reverse Engineering course&lt;/a&gt; yesterday and caught up on some much needed sleep after a few drinks at some local pubs. Got a chance to catch some of the talks today prior to flying out tomorrow morning to Barcelona for the weekend.&lt;br /&gt;
&lt;br /&gt;
FX had a well researched talk on &lt;a href=&quot;http://www.blackhat.com/html/bh-europe-08/bh-eu-08-speakers.html#Lindner&quot;&gt;Cisco IOS forensics&lt;/a&gt; that I greatly enjoyed. It appears the boys over at SABRE/Recurity have put together a pretty robust Cisco core dump analyzer and to my surprise they have made it available for use free of charge:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://cir.recurity-labs.com&quot;&gt;http://cir.recurity-labs.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The other event I really enjoyed today was the &lt;br /&gt;
&lt;a href=&quot;http://www.blackhat.com/html/bh-europe-08/bh-eu-08-speakers.html#West&quot;&gt;Iron Chef&lt;/a&gt; challenge. Apparently they had one of these at the Vegas Black Hat show, I had no idea. Essentially 2 teams are presented with a target and given 45 minutes to audit it. Their results are judged at the end of the 45 minutes by the audience and a winner is chosen. The chosen target was &lt;a href=&quot;http://www.jforum.net&quot;&gt;JForum&lt;/a&gt;, a web forum written in Java. The audience is allowed to play along; Neither Java nor web apps are my forte but I was playing around on Ero's laptop for a few minutes and found a persistent script injection flaw. Nothing too exciting but the contestants didn't do much better coming up with only a few theoretical possibilities. All in all I really like the idea of this Iron Chef track. They should provide a little more time and do something with binary analysis, that could be fun.&lt;br /&gt;
&lt;br /&gt;
There are some great talks lined up for tomorrow that unfortunately I will be missing. I was especially excited about the &lt;a href=&quot;https://www.blackhat.com/html/bh-europe-08/bh-eu-08-speakers.html#Weston&quot;&gt;DTRACE talk&lt;/a&gt; but was unable to change my flight.</description>
                    </item>
                <item>
            <title>PyDbg Hacks</title>
                            <pubDate>Thu, 23 Aug 2007 00:56:17 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/869/PyDbg_Hacks</link>
                                        <author>pedram &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Just added some PyDbg based hacks to the public repository (should show up within an hour max of this post). Here is a description of what was added:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;just_in_time_debugger.py&lt;/b&gt;&lt;br /&gt;
PyDbg implementation of a script that can be set as the Just-In-Time debugger. Logs the crash context to disk. I'll be blogging about / giving out a standalone executable based on this script for those of you who want to e-mail all your crash dumps to ... me ;-)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;stack_integrity_monitor.py&lt;/b&gt;&lt;br /&gt;
Automatically locate the source of a stack overflow. This has already been released, just hasn't been previously part of the repo. For more info see the related &lt;a href=&quot;https://www.openrce.org/blog/view/723/Pin_Pointing_Stack_Smashes&quot;&gt;blog entry&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;pydbgc.py&lt;/b&gt;&lt;br /&gt;
Cody's PyDbg command line interface library. This is pretty cool, you can import it to drop a user into an interactive PyDbg shell at any point during execution. Gives you WinDbg-esque commands. One of the cooler features of this hack is that it allows you to step backwards, really.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;push_pop_unpacker.py&lt;/b&gt;&lt;br /&gt;
This is a quick and dirty PyDbg implementation of a known generic technique for stopping an unpacker at OEP. This script was written during Ero and I's 2007 &lt;a href=&quot;http://www.blackhat.com/html/bh-usa-07/train-bh-us-07-pa.html&quot;&gt;Reverse Engineering&lt;/a&gt; class at BlackHat. It took like 20 minutes to write, gotta love PyDbg.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;null_selector_mem_monitor_poc.py&lt;/b&gt;&lt;br /&gt;
Pydbg implementation of skape's null selector mem-monitor technique. Read more about it on &lt;a href=&quot;http://www.uninformed.org/?v=7&amp;amp;a=1&quot;&gt;Uninformed Journal&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Get all the new goodies at &lt;a href=&quot;http://paimei.openrce.org&quot;&gt;http://paimei.openrce.org&lt;/a&gt;.</description>
                    </item>
                <item>
            <title>iPhone Gripes</title>
                            <pubDate>Tue, 24 Jul 2007 23:20:43 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/826/iPhone_Gripes</link>
                                        <author>pedram &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Based on Apple's history of releasing crappy first-rev products I was going to wait for the next release prior to purchasing the iPhone. An unfortunate drunken phone accident this weekend however accelerated my purchase plans.&lt;br /&gt;
&lt;br /&gt;
First, I'll say something nice. The visual voicemail feature of the iPhone is very elegant. I deplore voicemail, to the point that anyone who knows me well knows to never leave me one. With the iPhone I actually look forward to voicemail now. You get a list of who called and at what time. You can click to play, fast forward, rewind. It's how voicemail should be. None of the nonsense of &amp;quot;hit 1 to listen to new messages, 3 for the next, 7 to erase....&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now the ugly. What were the iPhone devs smoking when they made the following oversights:&lt;br /&gt;
&lt;br /&gt;
* &lt;b&gt;No custom ring tone.&lt;/b&gt; A $650 device with 8 gigs worth of mp3's and I'm limited to choosing between sounds such as a dog bark and a duck?&lt;br /&gt;
&lt;br /&gt;
* &lt;b&gt;Proprietary headphone jack.&lt;/b&gt; Why couldn't they make the jack cross-compatible with standard head phones? Probably because they want to up-sell you on cute, white, headphone adapters.&lt;br /&gt;
&lt;br /&gt;
* &lt;b&gt;No copy and paste.&lt;/b&gt; Manually typing in WEP keys sucks. Aside from that I could have &lt;i&gt;maybe&lt;/i&gt; lived without copy/paste ... until I discovered the next atrocity.&lt;br /&gt;
&lt;br /&gt;
* &lt;b&gt;NO GROUP OR MULTIUSER TEXT MESSAGING!&lt;/b&gt; This is completely unacceptable. Every cell phone on the face of the planet has this capability. I'm especially upset about this because I text like a &lt;a href=&quot;http://slashdot.org/article.pl?sid=07/07/22/1717244&quot;&gt;16 year old girl&lt;/a&gt;. Organizing outings, after parties, etc. without group texting is next to impossible.&lt;br /&gt;
&lt;br /&gt;
* &lt;b&gt;Keyboard doesn't flip sideways.&lt;/b&gt; Flipping the phone sideways does not flip the keyboard sidways (unless you are in the browser). Typing on the widescreen keyboard is much easier and should be available for texting and e-mails. Retarded.&lt;br /&gt;
&lt;br /&gt;
How's everyone else doing with theirs?</description>
                    </item>
                <item>
            <title>Greatest Book Dedication Ever?</title>
                            <pubDate>Fri, 06 Jul 2007 19:18:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/800/Greatest_Book_Dedication_Ever?</link>
                                        <author>pedram &lt;email-suppressed@example.com&gt;</author>
                                                    <description>Not to brag or anything, but who can deny this as the greatest book dedication the world has ever seen:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://safari.oreilly.com/9780321446114/copyrightpg#X2ludGVybmFsX1ByaW50RmlkZWxpdHk/eG1saWQ9OTc4MDMyMTQ0NjExNC9jb3B5cmlnaHRwZyZpbWFnZXBhZ2U9dg==&quot;&gt;Fuzzing: Brute Force Vulnerability Discovery - Dedication&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you are interested in buying the book:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/exec/obidos/redirect?path=ASIN/0321446119&amp;amp;link_code=as2&amp;amp;camp=1789&amp;amp;tag=openreverseco-20&amp;amp;creative=9325&quot;&gt;Amazon&lt;/a&gt;</description>
                    </item>
                <item>
            <title>Pin Pointing Stack Smashes</title>
                            <pubDate>Tue, 08 May 2007 23:35:21 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/723/Pin_Pointing_Stack_Smashes</link>
                                        <author>pedram &lt;email-suppressed@example.com&gt;</author>
                                                    <description>This was originally posted over on my &lt;a href=&quot;http://dvlabs.tippingpoint.com/blog/5/Pin-Pointing-Stack-Smashes&quot;&gt;company blog site&lt;/a&gt; (TippingPoint DVLabs). Since the DVLabs blog is new I'm cross posting here to draw some traffic to it. Tracking down stack overflows is tedious work. Especially when the entire stack is blown away leaving you with crash dumps like the excerpt following this paragraph. This crash dump is from an actual process in case you are curious. Specifically, it is from one of the bugs detailed in &lt;a href=&quot;http://dvlabs.tippingpoint.com/advisory/TPTI-07-02&quot;&gt;TPTI-07-02: Trend Micro ServerProtect eng50.dll Stack Overflow Vulnerabilities&lt;/a&gt;. It's pretty obvious that it's game over for our target here. The important question to answer at this juncture is, where is the bug? There are a number of approaches you can take to manually handle this situation. Please add any creative ones you may have as a comment.&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[INVALID]:41414141 Unable to disassemble at 41414141 from thread 568&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;caused access violation when attempting to read from 0x41414141&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CONTEXT DUMP&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EIP: 41414141 Unable to disassemble at 41414141&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EAX: 00000001 (&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EBX: 0259eedc (&amp;nbsp;&amp;nbsp;39448284) - AAAAAAAAAAAAA.....AAAAAAAAAAAAAAAAAAAAA (stack)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ECX: 00000000 (&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EDX: ffffffff (4294967295) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EDI: 00000000 (&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ESI: 0259f102 (&amp;nbsp;&amp;nbsp;39448834) - AAAAAAAAAAAAA.....AAAAAAAAAAAAAAAAAAAAA (stack)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EBP: 00000001 (&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ESP: 0259e2d4 (&amp;nbsp;&amp;nbsp;39445204) - AAAAAAAAAAAAA.....AAAAAAAAAAAAAAAAAAAAA (stack)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+00: 41414141 (1094795585) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+04: 41414141 (1094795585) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+08: 41414141 (1094795585) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+0c: 41414141 (1094795585) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+10: 41414141 (1094795585) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+14: 41414141 (1094795585) - N/A&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disasm around:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0x41414141 Unable to disassemble&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
In this blog entry, I present &lt;a href=&quot;http://dvlabs.tippingpoint.com/pub/pamini/stack_integrity_monitor.py&quot;&gt;stack_integrity_monitor.py&lt;/a&gt;. A command line utility implemented in under 150 lines of Python code which provides an automated solution to the task of tracking down the source of a stack overflow. This Python utility leverages PyDbg, a pure-Python win32 debugger interface. PyDbg is part of the larger &lt;a href=&quot;http://www.openrce.org/downloads/details/208/PaiMei-Reverse-Engineering-Framework&quot;&gt;PaiMei Reverse Engineering Framework&lt;/a&gt;. If you've never heard of PaiMei before, follow the link to learn more.&lt;br /&gt;
&lt;br /&gt;
The main reason stack overflows are exploitable is because control information is stored in the same medium as volatile user-controllable data. If we can move or mirror the call-chain &amp;quot;out of band&amp;quot;, then we can verify the integrity of the stack at run-time. Skipping over the intricate details, here is the high level overview of how the utility works:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 1. Instantiate a debugger object and attach to the target program.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 2. Set a breakpoint where we want the trace to start, this can be as simple as setting a break on recv().&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 3. Once the breakpoint is hit, set the active thread to single step.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 4. When a CALL instruction is reached, copy the stack and return addresses to an internal &amp;quot;mirror&amp;quot; list.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 5. When a RET instruction is reached, walk through the &amp;quot;mirror&amp;quot; list and verify that the values match the actual stack.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; 6. When the last saved return address is reached, pop it off the internal &amp;quot;mirror&amp;quot; list.&lt;br /&gt;
&lt;br /&gt;
If during the stack integrity check a mismatch is found, then not only do we know that a stack overflow has occurred, but we know which functions frame the overflow originated in and we can pinpoint the cause of the overflow. Using Trend Micro again as a real-world example, the previously shown (and mostly useless) crash dump turns into the following (very useful) output when launching the target under the peering eyes of stack_integrity_monitor.py:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259fc24: TmRpcSrv.dll.65741721&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259e7b4: StRpcSrv.dll.65671190&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259e7a8: Eng50.dll.61181d8c&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259e790: Eng50.dll.611819a0&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259e564: Eng50.dll.61181a50&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259e2d0: Eng50.dll.61190fa4 -- 41414141&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0259e03c: Eng50.dll.61190fd2&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Examining the vicinity of the last return address in the list, we find:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;61190FC7 lea edx, [esp+288h+szShortPath]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;61190FCB push esi&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;61190FCC push edx&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;61190FCD call _wcscpy&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;61190FD2 add esp, 8&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
The wcscpy() is the source of the stack overflow. The origin of the overflowed buffer is obvious in this case, it resides in the current function frame with a size of 600 bytes. Had the overflow occurred in a buffer originating further up the call chain the stack_integrity_monitor would have told us. In this case we see the stack mismatch occurred at stack address 0x0259e2d0 which should contain the return address 0x61190fa4 but instead contains 0x41414141. Had even a single byte of the return address been overwritten, stack_integrity_monitor would have detected it.&lt;br /&gt;
&lt;br /&gt;
This handy command line utility has been checked into the PaiMei SVN repository and will be distributed with future releases of the reverse engineering framework. Future improvements may include speed boosts and perhaps additionally mirroring saved frame pointers. This quick hack was written in less than 2 hours and motivated from necessity, on a day where I happened to need to track down a dozen or so stack overflows. Give it a try, let me know what you think.</description>
                    </item>
            </channel>
</rss>
