<?xml version="1.0" ?>
<?xml-stylesheet href="" type="text/css"?>

<Channel xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns="http://purl.org/net/rss1.1#"
         xmlns:p="http://purl.org/net/rss1.1/payload#"
         rdf:about="http://www.vnsecurity.net/Members/mikado">

    <title>mikado</title>
    <link>http://www.vnsecurity.net/Members/mikado</link>

    

    <image rdf:parseType="Resource">
        <title>mikado</title>
        <url>http://www.vnsecurity.net/logo.png</url>
    </image>

    <items rdf:parseType="Collection">
        
        <item rdf:about="http://www.vnsecurity.net/Members/mikado/archive/2007/07/12/another-way-to-inject-a-dll">
            <title>Another way to inject a DLL</title>
            <link>http://www.vnsecurity.net/Members/mikado/archive/2007/07/12/another-way-to-inject-a-dll</link>
            <description>There's nothing new. This method is based on method CreateRemoteThread() and CEngine::EngineTrap() in my previous blog entry.</description>
            <p:payload xmlns="http://www.w3.org/1999/xhtml"
                       rdf:parseType="Literal"><p>Read this first: <a class="generated" href="archive/2007/07/10/ollydbg-plugin-catcha-v1-1-catcha-anywhere">OllyDbg plugin: Catcha! v1.1 - Catcha anywhere</a><br></p><p>Nothing special :D Just write a trap function that call LoadLibrary() function... <br></p><p>Pros:<br>- We have an advantage that we don't have to call CreateRemoteThread() function.<br></p><p>Cons:<br>- Must pause target process to hook its EntryPoint :D.<br></p></p:payload>
            <dc:date>2007-07-12T03:03:35+00:00</dc:date>
            <dc:modified>2007/07/12 11:44:04.338 GMT+0</dc:modified>
            <dc:creator>mikado</dc:creator>
            
            
            <dc:subject>Reverse Engineering</dc:subject>
            
        </item>
        
        
        <item rdf:about="http://www.vnsecurity.net/Members/mikado/archive/2007/07/10/ollydbg-plugin-catcha-v1-1-catcha-anywhere">
            <title>OllyDbg plugin: Catcha! v1.1 - Catcha anywhere</title>
            <link>http://www.vnsecurity.net/Members/mikado/archive/2007/07/10/ollydbg-plugin-catcha-v1-1-catcha-anywhere</link>
            
            <p:payload xmlns="http://www.w3.org/1999/xhtml"
                       rdf:parseType="Literal"><p><a title="OllyDbg plugin: Catcha! v1.1" class="generated" href="/vnsec/Members/internal/public/ollydbg-plugin-catcha/Catcha-1.1.rar">OllyDbg plugin: Catcha! v1.1</a><br></p><p>In order to reach the target program EntryPoint, we call CEngine::EngineTrap() function below before resuming the target program to hook its EntryPoint and raise debug exception by INT3 instruction then we can attach to it.<br>
</p><pre>///pAddress: the address inside target process (the EntryPoint in our case) that will be hooked with trap function.<br>VOID CEngine::EngineTrap(LPVOID pAddress)<br>{<br>	HANDLE hProcess = NULL, hLibRemote = NULL;<br>	UCHAR pEntryPointOpcodes[5] = {0,};<br>	//Trap function opcodes<br>	UCHAR pTrap[] = {0x50,				// 0 - PUSH EAX				; Save EAX<br>			 0xB8, 0x00, 0x00, 0x00, 0x00,	// 1 - MOV EAX,XXXXXXXX			; EAX = XXXXXXXX = pAddress<br>			 0xC6, 0x00, 0xFF,		// 6 - MOV BYTE PTR DS:[EAX],0FF	;\<br>			 0xC6, 0x40, 0x01, 0xFF,	// 9 - MOV BYTE PTR DS:[EAX+1],0FF	; |<br>			 0xC6, 0x40, 0x02, 0xFF,	//13 - MOV BYTE PTR DS:[EAX+2],0FF	; | Restore original opcodes at pAddress<br>			 0xC6, 0x40, 0x03, 0xFF,	//17 - MOV BYTE PTR DS:[EAX+3],0FF	; |<br>			 0xC6, 0x40, 0x04, 0xFF,	//21 - MOV BYTE PTR DS:[EAX+4],0FF	;/<br>			 0x58,				//25 - POP EAX				; Restore EAX<br>			 0xCC,				//26 - INT3				; Raise debug exception<br>			 0xE9, 0x00, 0x00, 0x00, 0x00	//27 - JMP YYYYYYYY			; YYYYYYYY = relative address value of pAddress<br>			};<br>	DWORD nOldProtect;<br><br>	do {<br>		//Open target process<br>		hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, m_ProcessInfo.m_nProcessId);<br>		if (!hProcess) {<br>			EngineLog("Error: CEngine::EngineTrap() -&gt; ::OpenProcess()");<br>			EngineError();<br>			break;<br>		}<br><br>		//Allocate memory space inside target process for trap function<br>		//hLibRemote = allocated virtual address inside target process<br>		hLibRemote = ::VirtualAllocEx(hProcess,<br>					      NULL,<br>					      sizeof(pTrap),<br>					      MEM_COMMIT,<br>					      PAGE_READWRITE);<br>		if (!hLibRemote) {<br>			EngineLog("Error: CEngine::EngineTrap() -&gt; ::VirtualAllocEx()");<br>			EngineError();<br>			break;<br>		}<br><br>		//Ensure that we can read/write/execute sizeof(pEntryPointOpcodes) bytes at pAddress<br>		if (!::VirtualProtectEx(hProcess,<br>					(LPVOID)(m_ProcessInfo.m_nImageBase + m_ProcessInfo.m_nAddressOfEntryPoint),<br>					sizeof(pEntryPointOpcodes),<br>					PAGE_EXECUTE_READWRITE,<br>					&amp;nOldProtect)) {<br>			EngineLog("Error: CEngine::EngineTrap() -&gt; ::VirtualProtectEx()");<br>			EngineError();<br>			break;<br>		}<br><br>		//Ensure that we can read/write/execute sizeof(pTrap) bytes at hLibRemote<br>		if (!::VirtualProtectEx(hProcess,<br>					(LPVOID)hLibRemote,<br>					sizeof(pTrap),<br>					PAGE_EXECUTE_READWRITE,<br>					&amp;nOldProtect)) {<br>			EngineLog("Error: CEngine::EngineTrap() -&gt; ::VirtualProtectEx()");<br>			EngineError();<br>			break;<br>		}<br><br>		//Save sizeof(pEntryPointOpcodes) bytes at pAddress in pEntryPointOpcodes<br>		if (!::ReadProcessMemory(hProcess,<br>					 (LPVOID)(m_ProcessInfo.m_nImageBase + m_ProcessInfo.m_nAddressOfEntryPoint),<br>					 (LPVOID)pEntryPointOpcodes,<br>					 sizeof(pEntryPointOpcodes),<br>					 NULL)) {<br>			EngineLog("Error: CEngine::EngineTrap() -&gt; ::ReadProcessMemory()");<br>			EngineError();<br>			break;<br>		}<br><br>		//Repair trap function<br><br>		//XXXXXXXX = pAddress<br>		*(PDWORD)(pTrap + 2) = (DWORD)pAddress;<br><br>		//Calculate value for JMP instruction<br>		//YYYYYYYY = relative address value of pAddress<br>		*(PDWORD)(pTrap + 28) = (DWORD)pAddress - ((DWORD)hLibRemote + sizeof(pTrap));<br><br>		//Restore original opcodes at pAddress<br>		pTrap[8] = pEntryPointOpcodes[0];<br>		pTrap[12] = pEntryPointOpcodes[1];<br>		pTrap[16] = pEntryPointOpcodes[2];<br>		pTrap[20] = pEntryPointOpcodes[3];<br>		pTrap[24] = pEntryPointOpcodes[4];<br><br>		//Replace opcodes at pAddress with JMP instruction to trap function<br>		pEntryPointOpcodes[0] = 0xE9;<br>		//Calculate value for JMP instruction<br>		*(PDWORD)(pEntryPointOpcodes + 1) = (DWORD)hLibRemote - ((DWORD)pAddress + sizeof(pEntryPointOpcodes));<br><br>		//Write our codes into target process<br><br>		if (!::WriteProcessMemory(hProcess,<br>					  pAddress,<br>					  (LPVOID)pEntryPointOpcodes,<br>					  sizeof(pEntryPointOpcodes),<br>					  NULL)) {<br>			EngineLog("Error: CEngine::EngineHookEntryPoint() -&gt; ::WriteProcessMemory()");<br>			EngineError();<br>			break;<br>		}<br><br>		if (!::WriteProcessMemory(hProcess,<br>					  (LPVOID)hLibRemote,<br>					  (LPVOID)pTrap,<br>					  sizeof(pTrap),<br>					  NULL)) {<br>			EngineLog("Error: CEngine::EngineTrap() -&gt; ::WriteProcessMemory()");<br>			EngineError();<br>			break;<br>		}<br>	}<br>	while (FALSE);<br><br>	::CloseHandle(hProcess);<br><br>	EngineLog("Done: CEngine::EngineTrap()");<br>}<br></pre>
<br>
<p>Besides, this function is also used to hook and trap at any address inside target process. It will be useful for attaching OllyDbg after bypassing some codes we are not interested in (e.g: anti-debugger codes :D). Because I don't have much time at this moment, I will add this option in next version of Catcha!.</p><p><i>mikado.</i><br></p>

P.S: As lamer's comment, the next feature can only be applied to applications that don't handle INT3 exception themselves. Another problem is that this version is still not be able to catch .NET applications because their EntryPoint is located in mscoree.dll.<br></p:payload>
            <dc:date>2007-07-10T03:23:47+00:00</dc:date>
            <dc:modified>2007/07/10 08:29:18.884 GMT+0</dc:modified>
            <dc:creator>mikado</dc:creator>
            
            
            <dc:subject>Reverse Engineering</dc:subject>
            
        </item>
        
        
        <item rdf:about="http://www.vnsecurity.net/Members/mikado/archive/2007/07/06/ollydbg-plugin-catcha-v1.0">
            <title>OllyDbg plugin: Catcha! v1.0</title>
            <link>http://www.vnsecurity.net/Members/mikado/archive/2007/07/06/ollydbg-plugin-catcha-v1.0</link>
            <description>Sometimes you don't know how to start a program correctly
from OllyDgb. Catcha! plugin will help you to attach to your
program automatically as soon as possible each time your
program runs (outside OllyDbg).</description>
            <p:payload xmlns="http://www.w3.org/1999/xhtml"
                       rdf:parseType="Literal"><a title="OllyDbg plugin: Catcha! v1.0" class="generated" href="/vnsec/Members/internal/public/ollydbg-plugin-catcha/Catcha-1.0.rar">OllyDbg plugin: Catcha! v1.0</a><br>
<pre>Catcha! v1.0<br>Coded by mikado @ vnsecurity, 4vn<br>Website: http://www.vnsecurity.net - http://www.4vn.org<br>Email: mikado[at]4vn[dot]org<br><br>[ About ]<br>Sometimes you don't know how to start a program correctly<br>from OllyDgb. Catcha! plugin will help you to attach to your<br>program automatically as soon as possible each time your<br>program runs (outside OllyDbg).<br><br>It works like Olly De-Attach Helper plugin:<br>http://www.openrce.org/downloads/details/185/Olly%20De-Attach%20Helper<br><br>Catcha! has more advantages than Olly De-Attach Helper.<br>It helps reversers not to miss many opcodes before attaching<br>target program.<br><br>Check it out! Have fun and feel free to contact me.<br><br>[ Instructions ]<br>- Copy Catcha!.dll and Catcha!.sys to OllyDbg plugin directory.<br>- First, select target program by chosing menu:<br>  Plugins -&gt; Catcha! -&gt; Select Catcha! target.<br>- Run target program outside OllyDbg.<br>  It will be attached in OllyDbg automatically as soon as possible.<br>- Press F9 to continue running program or,<br>  right click on Disassembler window and chose Thread -&gt; Main<br>  on Popup menu to switch to program's main thread and continue<br>  your debug session.<br><br>[ History ]<br>2007.07.06:<br>- Version 1.0 released.<br><br>[ Known bugs ]<br>1. Target program can only be attached automatically one time.<br>   You have to restart OllyDbg in order for Catcha! to work correctly.<br>2. Only tested on Windows XP SP2. The kernel driver was built<br>   on WinDDK with Windows XP Build Environment.<br><br>[ TODO ]<br>- Fix bug (1).<br>- Implement de-attach function without closing target program.<br><br>mikado.<br></pre></p:payload>
            <dc:date>2007-07-06T16:53:44+00:00</dc:date>
            <dc:modified>2007/07/10 08:29:18.932 GMT+0</dc:modified>
            <dc:creator>mikado</dc:creator>
            
            
            <dc:subject>Reverse Engineering</dc:subject>
            
        </item>
        
    </items>
</Channel>

