能力值:
( LV12,RANK:250 )
2 楼
在shoooo发布的贴中没人提出过这个问题,我想应该是大家都懂了,但是我找遍了整个论坛找不到相关的贴子。
能力值:
( LV12,RANK:250 )
3 楼
ExitProcess -> Patch to ExitThread 不理解
这个懂了
004AD0B0 /$ 55 push ebp
004AD0B1 |. 8BEC mov ebp, esp
004AD0B3 |. 8B45 08 mov eax, dword ptr [ebp+8]
004AD0B6 |. 50 push eax ; /ExitCode
004AD0B7 \. E8 2C1F0000 call <jmp.&KERNEL32.ExitProcess> 将这个patch成ExitThread函数
004AD0BC . 5D pop ebp
004AD0BD . C3 retn
能力值:
( LV13,RANK:530 )
4 楼
simple and easy...you really should try to compile a program for testing...when you try to call Resource function what would you do usually.and for injection to another process what's diffirent between your injected module and exe.
能力值:
( LV12,RANK:250 )
5 楼
ths for your suggestion.
can you give more tips.
能力值:
( LV12,RANK:250 )
6 楼
Get the Resource ID?Am I right?
能力值:
( LV13,RANK:530 )
7 楼
From MSDN documents we know that..if we wanna go anything from resources we need a hModule for arg (e.t.
HRSRC FindResource( HMODULE hModule,
LPCTSTR lpName,
LPCTSTR lpType
);)
you can see that first arg.
but OllyDbg may thought it runs in exe.so just gives the simplest arg
hModule
[in] Handle to the module whose executable file contains the resource. A value of NULL specifies the module handle associated with the image file that the operating system used to create the current process.
NULL
or GetModuleHandle(NULL);
So problems occur....
能力值:
( LV12,RANK:250 )
8 楼
Ths I know what to do the next!!!! Thank you very much!!!!
能力值:
( LV12,RANK:250 )
9 楼
00B1AF44 /$ 53 push ebx
00B1AF45 |. 56 push esi
00B1AF46 |. 57 push edi
00B1AF47 |. E8 88E3FFFF call 00B192D4
00B1AF4C |. 68 9113BC00 push 00BC1391 ; /ResourceType = "KNOWNRESTYPE"
00B1AF51 |. 68 8713BC00 push 00BC1387 ; |ResourceName = "RES_KNOWN"
00B1AF56 |. 6A 00 push 0 ; |hModule = NULL
00B1AF58 |. E8 A3400A00 call <jmp.&KERNEL32.FindResourceA> ; \FindResourceA
00B1AF5D |. 85C0 test eax, eax
00B1AF5F |. 0F84 3E010000 je 00B1B0A3
00B1AF65 |. 50 push eax ; /hResource
00B1AF66 |. 6A 00 push 0 ; |hModule = NULL
00B1AF68 |. E8 D1410A00 call <jmp.&KERNEL32.LoadResource> ; \LoadResource
00B1AF6D |. 85C0 test eax, eax
00B1AF6F |. 0F84 2E010000 je 00B1B0A3
00B1AF75 |. 50 push eax ; /hResource
00B1AF76 |. E8 C9410A00 call <jmp.&KERNEL32.LockResource> ; \LockResource
There are a lot of Resource Function using 0 as the base of module address in the od modified by shoooo.
In your Opinion,I think it must be modify the real base address.Because it doesn't in ox00400000.(inject)
能力值:
( LV12,RANK:250 )
10 楼
Found patching the GetModuleHandle
hehe!!!
00BBD348 |. 50 push eax
00BBD349 |. 53 push ebx
00BBD34A |. 6A 00 push 0
00BBD34C |. 6A 00 push 0
00BBD34E |. E8 15230000 call 00BBF668 ; patch GetModuleHandle
00BBD353 |. 50 push eax
00BBD354 |. FF56 18 call dword ptr [esi+18]
00BBD357 |. 83C4 10 add esp, 10
00BBD35A |. 50 push eax ; /Arg1
00BBD35B |. E8 3CF2FFFF call 00BBC59C ; \Ollydbg.0091C59C
能力值:
( LV12,RANK:250 )
11 楼
好总结一下
一 修改PE头Characteristics属性
自己添加DLLMAIN函数,还有一个就获取base address的函数
00BBF650 >/$ E8 00000000 call 00BBF655 //DllMain函数
00BBF655 |$ 5A pop edx
00BBF656 |. 83EA 05 sub edx, 5
00BBF659 |. 8B4424 04 mov eax, dword ptr [esp+4]
00BBF65D |. 8942 FC mov dword ptr [edx-4], eax
00BBF660 |. 6A 01 push 1
00BBF662 |. 58 pop eax
00BBF663 \. C2 0C00 retn 0C
00BBF666 90 nop
00BBF667 90 nop
00BBF668 /$ E8 00000000 call 00BBF66D //GetBaseAddress函数
00BBF66D |$ 58 pop eax
00BBF66E |. 83E8 05 sub eax, 5
00BBF671 |. 83E8 1C sub eax, 1C
00BBF674 |. 8B00 mov eax, dword ptr [eax]
00BBF676 \. C2 0400 retn 4
二 删除TlsTable当然你不删除也行,但一定要把
00B1102F E8 70180A00 call 00BB28A4
00B11034 E8 D3240A00 call 00BB350C
00B11039 6A 00 push 0
00B1103B 90 nop 一定要nop掉,因为线程本地存储在其它线程访问会导入访问异常
00B1103C 90 nop
00B1103D 90 nop
00B1103E 90 nop
00B1103F 90 nop
00B11040 59 pop ecx
00B11041 68 C400BC00 push 00BC00C4
上面代码在EP附近
三 patch ExitProcess to ExitThread程序退出当然是退出线程,因为此时被注入到Explorer进程中。
四 patch GetModuleHandle For Resource
00BBD348 |. 50 push eax
00BBD349 |. 53 push ebx
00BBD34A |. 6A 00 push 0
00BBD34C |. 6A 00 push 0
00BBD34E |. E8 15230000 call 00BBF668 //看到没函数在这里被调用
00BBD353 |. 50 push eax
00BBD354 |. FF56 18 call dword ptr [esi+18]
00BBD357 |. 83C4 10 add esp, 10
00BBD35A |. 50 push eax ; /Arg1
00BBD35B |. E8 3CF2FFFF call 00BBC59C ; \Ollydbg.0091C59C
能力值:
( LV12,RANK:250 )
12 楼
在多线程编程中, 同一个变量, 如果要让多个线程共享访问, 那么这个变量可以使用关键字volatile进行声明; 那么如果一个变量不想使多个线程共享访问, 那么该怎么办呢? 呵呵, 这个办法就是TLS, 线程本地存储. 它的使用非常之简单, 只要对变量的声明使用__declspec(thread)就OK了. 下面我来举一个例子, 结合注释, 相信大家马上就能知道其”奥秘”了.
#include<windows.h>
#include <stdio.h> __declspec(thread) int g_nData = 0; //这就是两个线程都要访问的变量
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
char szMsg[40] = {0};
sprintf(szMsg, "Auxi thread, g_nData: %d", g_nData);
MessageBox(NULL, szMsg, "AuxiThread", MB_ICONINFORMATION);
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DWORD dwId;
g_nData = 10; //主线程将该变量赋值为10,然而辅线程仍显示为0
HANDLE hThread = CreateThread(NULL, 1024, ThreadProc, NULL, 0, &dwId);
::WaitForSingleObject(hThread,INFINITE); //等待符线程执行结束
char szMsg[40] = {0};
sprintf(szMsg, "Result: %d", g_nData);
MessageBox(NULL, szMsg, "MainThread", MB_ICONINFORMATION);
return 0;
}
能力值:
( LV12,RANK:250 )
13 楼
感谢shoooo,foxabu