<?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>Bypassing OllyAdvanced</title>
                            <pubDate>Tue, 17 Aug 2010 10:16:14 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1579/Bypassing_OllyAdvanced</link>
                                        <author>grzonu &lt;email-suppressed@example.com&gt;</author>
                                                    <description>I`m currently doing research on some method to detect &amp;amp; disconnect a debugger. &lt;br /&gt;
For example, I use NtQuerySystemInformation with SystemHandleInformation parameter to search for Handles to my process (Handle type = 0x07) and the Debug Handles (type == 0x0B).&lt;br /&gt;
If a process has both handles, then it's probably a debugger that is debugging our process.&lt;br /&gt;
We can then remove the debugger using ZwRemoveProcessDebug.&lt;br /&gt;
But... &lt;br /&gt;
If the debugger is using the OllyAdvance plugin, then if we use NtQuerySystemInformation we get an empty list of debugger-owned handles. Also, if we use NtQueryProcessInformation to get parent process ID, we get the ID of our own process and so, we can`t open the debugger`s (parents) process, nor duplicate handles.&lt;br /&gt;
It seems that if we use SYSCALL to call these functions, OllyAdvance is modyfing the results of calls. However, If we use INT 2E to perform this call to the functions, OllyAdvanced doesn't &amp;quot;work&amp;quot; and we get the proper, unmodified, results ;)&lt;br /&gt;
It seems that OllyAdvance uses a hook on the function that sysexit return to (ntdll.KiFastSystemCallRet), so it can modify the results. On the other hand, INT 2E don`t use sysexit to return to User Mode, so OllyAdvance cant`t hook this.&lt;br /&gt;
We can now both easily detect the debugger and disconnect it ;)</description>
                    </item>
            </channel>
</rss>
