Load PE from memory(反取证)(未完)
Article 1:Loading Win32/64 DLLs "manually" without LoadLibrary()
The most important steps of DLL loading are:
- Mapping or loading the DLL into memory.
- Relocating offsets in the DLL using the relocating table of the DLL (if present).
- Resolving the dependencies of the DLL, loading other DLLs needed by this DLL and resolving the offset of the needed functions.
- Calling its entrypoint (if present) with the
DLL_PROCESS_ATTACH
parameter.
I wrote the code that performed these steps but then quickly found out something is not OK: This loaded DLL doesn't have a valid HMODULE
/HINSTANCE
handle and many windows functions expect you to specify one (for example, GetProcAddress()
, CreateDialog()
, and so on...). Actually the HINSTANCE
handle of a module is nothing more than the address of the DOS/PE header of the loaded DLL in memory.I tried to pass this address to the functions but it didn't work because windows checks whether this handle is really a handle and not only the contents of memory! This makes using manually loaded DLLs a bit harder!I had to write my own GetProcAddress()
because the windows version didn't work with my DLLs.Later I found out that I want to use dialog resources in the DLL and CreateDialog()
also requires a module handle to get the dialog resources from the DLL. For this reason I invented my custom FindResource()
function that works with manually loaded DLLs and it can be used to find dialog resources that can be passed to the CreateDialogIndirect()
function. You can use other types of resources as well in manually loaded DLLs if you find a function for that resource that cooperates with FindResource()
. In this tip you get the code for the manual DLL loader and GetProcAddress()
, but I post here the resource related functions in another tip.
Limitations
- The loaded DLL doesn't have a
HMODULE
so it makes life harder especially when its about resources. - The
DllMain()
doesn't receiveDLL_THREAD_ATTACH
andDLL_THREAD_DETACH
notifications. You could simulate this by creating a small DLL that you load with normalLoadLibrary()
and from theDllMain()
of this normally loaded DLL you could call the entrypoint of your manually loaded DLLs in case ofDLL_THREAD_ATTACH/DLL_THREAD_DETACH
.(建立一个普通的用LoadLibrary()加载起来的dll,从这个正常加载起来的dll的DLLMain(),你可以调用手动加载的DLL的入口点) - If your DLL imports other DLLs, then the other DLLs are loaded with the WinAPI
LoadLibrary()
. This is actually not a limitation, just mentioned it for your information. Actually it would be useless to start loading for example kernel32.dll with manual dll loading, most system DLLs would probably disfunction/crash! - DLLs that make use of SEH *may* fail. The fact that the DLL contains SEH related code alone isn't a problem but the __try blocks in the loaded DLL won't be able to catch the exceptions because the
ntdll.dll!RtlIsValidHandler()
doesn't accept exception handler routines from the memory area of our manually loaded DLL (because this memory area isn't mapped from a PE file). This is a problem only if an exception is raised inside a __try block of the DLL (because windows can't run the exception handler of the DLL and raises another exception that escapes the exception handler of the DLL - the result is usually a crash). - Whether the CRT works with manual DLL loading or not depends on several things. It depends on the actual CRT version you are using and the functions you call from the CRT. If you are using just a few simple functions (like printf) then the CRT may work. I've written my DLLs with /NODEFAULTLIB linker option that means you can't reach CRT functions and it reduces your DLL size considerably (like with 4K intros). But then you have to go with pure WinAPI! This can be quite inconvenient but you can overcome this by writing your own mini CRT. I've provided one such mini CRT in my C++ example without attempting to be comprehensive but it at least allows you to use the most basic C++ features: automatically initialized static variables, new/delete operators. BTW, if you are about to use this code then you should understand most of these problems and you should appreciate that writing C/C++ DLL without CRT is still much more convenient than writing something as an offset independent or relocatable assembly patch.
源码分析:
- TestDLL
定义一个结构体DLLInterface类型:里边是两个函数类型的指针AddNumbers和MyMessageBox
typedef struct DLLInterface
{
int (*AddNumbers)(int a, int b);
void (*MyMessageBox)(const char* message);
} DLLInterface;
对应的cpp文件中定义了两个函数:
int AddNumbers(int a, int b)
{
printf("DLL: AddNumbers(%d, %d)\n", a, b);
return a + b;
} void MyMessageBox(const char* message)
{
printf("DLL: MyMessageBox(\"%s\")\n", message);
MessageBoxA(NULL, message, "DLL MessageBox!", MB_OK);
}
然后将这两个函数作为指针传给上面定义的这样的一个结构体:
DLLInterface g_Interface =
{
AddNumbers,
MyMessageBox
};
将函数存储在dll文件的导出表中,__declspec(dllexport)表示被包含这个函数的程序之外的程序调用:
__declspec(dllexport) const DLLInterface* GetDLLInterface()
{
return &g_Interface;
}
DLLMain:
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
// With manual DLL loading you can not use DLL_THREAD_ATTACH and DLL_THREAD_DETACH.
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
printf("DLL: DLL_PROCESS_ATTACH\n");
// TODO
break;
case DLL_PROCESS_DETACH:
printf("DLL: DLL_PROCESS_DETACH\n");
// TODO
break;
default:
break;
}
return TRUE;
}
- LoadDLL:
这里是模拟加载DLL(LoadLibrary):
MODULE_HANDLE LoadModule(const char* dll_path)
{
LOAD_DLL_INFO* p = new LOAD_DLL_INFO;
DWORD res = LoadDLLFromFileName(dll_path, , p);
if (res != ELoadDLLResult_OK)
{
delete p;
return NULL;
}
return p;
}
LoadDLLFromFileName中调用了:
ELoadDLLResult LoadDLLFromFileNameOffset(const char* filename, size_t dll_offset, size_t dll_size, int flags, LOAD_DLL_INFO* info)
{
ELoadDLLResult res;
FILE* f = fopen(filename, "rb");//filename就是testDLL的路径
if (!f)
return ELoadDLLResult_DLLFileNotFound;
res = LoadDLLFromCFile(f, dll_offset, dll_size, flags, info);
fclose(f);
return res;
}
再看LoadDLLFromCFile中的内容,这里值得说明:
ELoadDLLResult LoadDLLFromCFile(FILE* f, size_t dll_offset, size_t dll_size, int flags, LOAD_DLL_INFO* info)
{
LOAD_DLL_FROM_FILE_STRUCT ldffs = { f, dll_offset, dll_size };
return LoadDLL((LOAD_DLL_READPROC)&LoadDLLFromFileCallback, &ldffs, flags, info);
}
LOAD_DLL_READPROC是一个函数指针类型,定义如下:
//LOAD_DLL_READPROC是一个函数指针
typedef BOOL (*LOAD_DLL_READPROC)(void* buff, size_t position, size_t size, void* param);
将LoadDLLFromFileCallback作为参数传递给LoadDLL."LoadDLLFromFileCallback"这个函数起名的用意是显然的,就是为了说明这是一个CALLBACK函数
这个CALLBACK函数的源码如下:
static BOOL LoadDLLFromFileCallback(void* buff, size_t position, size_t size, LOAD_DLL_FROM_FILE_STRUCT* param)
{
if (!size)
return TRUE;
if ((position + size) > param->dll_size)
return FALSE;
fseek(param->f, param->dll_offset + position, SEEK_SET);
return fread(buff, , size, param->f) == size;//用fread的形式把数据读入内存,起到Load的作用
}
说白了,CALLBACK之所以叫回调,是因为他是为了“被(作为参数)调用”而存在的,而不是为了来调用别的函数。这里,LoadDLLFromFileCallback被LoadDLL调用,用和LoadDLLFromFileCallback函数同类型的函数指针作为参数,传入LoadDLL,也就是说传入LoadDLLFromFileCallback函数供LoadDLL使用。其实CALLBACK函数不止这一个,还有如下这个函数:
static BOOL LoadDLLFromMemoryCallback(void* buff, size_t position, size_t size, LOAD_DLL_FROM_MEMORY_STRUCT* param)
{
if (!size)
return TRUE;
if ((position + size) > param->dll_size)
return FALSE;
memcpy(buff, (char*)param->dll_data + position, size);//拷贝指定位置开始的指定大小的数据到buff
return TRUE;
}
LoadDLLFromMemoryCallback和LoadDLLFromFileCallback同为CALLBACK函数,他们的模型是一样的,他们都是用来被其它函数调用的,LoadDLL根据自身想实现的不同功能,选择调用不同的CALLBACK函数而已。
对比一下LoadDLLFromCFile,LoadDLLFromMemory其实只是在其内部调用的时候使用了不同的CALLBACK函数作为参数而已:
DWORD LoadDLLFromMemory(const void* dll_data, size_t dll_size, int flags, LOAD_DLL_INFO* info)
{
LOAD_DLL_FROM_MEMORY_STRUCT ldfms = { dll_data, dll_size };
return LoadDLL ((LOAD_DLL_READPROC)&LoadDLLFromMemoryCallback, &ldfms, flags, info);
}
LoadDLL函数源码部分:
这里可能是重点部分,需要学习研究的点也很多。
ELoadDLLResult LoadDLL(LOAD_DLL_READPROC read_proc, void* read_proc_param, int flags, LOAD_DLL_INFO* info)
{
LOAD_DLL_CONTEXT ctx;
ELoadDLLResult res;
BOOL finished_successfully = FALSE;
unsigned i; if (!read_proc)
return ELoadDLLResult_WrongFunctionParameters; ctx.sect = NULL;
ctx.loaded_import_modules_array = NULL;
ctx.import_modules_array_capacity = ;
ctx.num_import_modules = ;
ctx.dll_main = NULL;
__try
{
__try
{
res = LoadDLL_LoadHeaders(&ctx, read_proc, read_proc_param);//加载了DOS头、PE头、Section Table
if (res != ELoadDLLResult_OK)
return res; res = LoadDLL_AllocateMemory(&ctx, flags);//开辟了一块能容纳Sections大小的虚拟空间
if (res != ELoadDLLResult_OK)
return res; __try
{
res = LoadDLL_LoadSections(&ctx, read_proc, read_proc_param, flags);//Load Sections和Sections之前的内容
if (res != ELoadDLLResult_OK)
return res; res = LoadDLL_PerformRelocation(&ctx);
if (res != ELoadDLLResult_OK)
return res; res = LoadDLL_ResolveImports(&ctx);//填充IAT
if (res != ELoadDLLResult_OK)
return res; res = LoadDLL_SetSectionMemoryProtection(&ctx);
if (res != ELoadDLLResult_OK)
return res; res = LoadDLL_CallDLLEntryPoint(&ctx, flags);
if (res != ELoadDLLResult_OK)
return res; /* We finished!!! :) Filling in the callers info structure... */ if (info)
{
__try
{
info->size = sizeof(*info);
info->flags = flags;
info->image_base = ctx.image_base;
info->mem_block = ctx.image;
info->dll_main = ctx.dll_main;
info->export_dir_rva = ctx.hdr.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
info->loaded_import_modules_array = ctx.loaded_import_modules_array;
info->num_import_modules = ctx.num_import_modules;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return ELoadDLLResult_WrongFunctionParameters;
}
} finished_successfully = TRUE;
return ELoadDLLResult_OK;
}
__finally
{
if (!finished_successfully)
VirtualFree(ctx.image, , MEM_RELEASE); if (!finished_successfully || !info)
{
if (ctx.loaded_import_modules_array)
{
for (i=; i<ctx.num_import_modules; ++i)
FreeLibrary(ctx.loaded_import_modules_array[i]);
free(ctx.loaded_import_modules_array);
}
}
}
}
__finally
{
if (ctx.sect)
free(ctx.sect);
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return ELoadDLLResult_UnknownError;
}
}
模拟的FreeLibrary:
bool UnloadModule(MODULE_HANDLE handle)
{
bool res = FALSE != UnloadDLL(handle);
delete handle;
return res;
}
BOOL UnloadDLL(LOAD_DLL_INFO* info)
{
unsigned i;
BOOL res = TRUE; __try
{
if (!info || info->size!=sizeof(*info) || !info->image_base || !info->mem_block)
return FALSE; if (info->loaded_import_modules_array)//存放的是HMODULE
{
for (i=; i<info->num_import_modules; ++i)
FreeLibrary(info->loaded_import_modules_array[i]);
free(info->loaded_import_modules_array);
} if (!(info->flags & ELoadDLLFlag_NoEntryCall) && info->dll_main)
{
__try
{
res = info->dll_main(info->image_base, DLL_PROCESS_DETACH, NULL);//执行DLLmain的detach
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
res = FALSE;
}
} VirtualFree(info->mem_block, , MEM_RELEASE);
return res;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return FALSE;
}
}
模拟的GetProcAddress:
FARPROC MyGetProcAddress(HMODULE module, const char* func_name)
{
IMAGE_NT_HEADERS* hdr;
__try
{
if (((IMAGE_DOS_HEADER*)module)->e_magic != IMAGE_DOS_SIGNATURE)
return NULL;
hdr = (IMAGE_NT_HEADERS*)((DWORD_PTR)module + ((IMAGE_DOS_HEADER*)module)->e_lfanew); if (hdr->Signature != IMAGE_NT_SIGNATURE || hdr->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)
return NULL; return MyGetProcAddress_ExportDir(
hdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress,
(DWORD_PTR)module,
func_name
);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return NULL;
}
}
里边调用了:MyGetProcAddress_ExportDir,其实就是从export中获得函数的地址
FARPROC MyGetProcAddress_ExportDir(DWORD export_dir_rva, DWORD_PTR image_base, const char* func_name)
{
IMAGE_EXPORT_DIRECTORY* exp;
DWORD_PTR ord;
DWORD i; if (!export_dir_rva)
return NULL;
exp = (IMAGE_EXPORT_DIRECTORY*)(image_base + export_dir_rva);
ord = (DWORD_PTR)func_name; __try
{
if (ord < 0x10000)
{
/* Search for ordinal. */ if (ord < exp->Base)
return NULL;
ord -= exp->Base;
}
else
{
/* Search for name. */ for (i=; i<exp->NumberOfNames; ++i)
{
if ( !strcmp( (char*)(((DWORD*)(exp->AddressOfNames + image_base))[i] + image_base), func_name) )
{
ord = ((WORD*)(exp->AddressOfNameOrdinals + image_base))[i];
break;
}
}
} if (ord >= exp->NumberOfFunctions)
return NULL;
return (FARPROC)(((DWORD*)(exp->AddressOfFunctions + image_base))[ord] + image_base); }
__except (EXCEPTION_EXECUTE_HANDLER)
{
return NULL;
}
}
源码下载、说明:
http://www.codeproject.com/Tips/430684/Loading-Win-DLLs-manually-without-LoadLibrary
下面是一个德国人写的Loading a DLL from memory
This tutorial describes a technique how a dynamic link library (DLL) can be loaded from memory without storing it on the hard-disk first.
To emulate the PE loader, we must first understand, which steps are neccessary to load the file to memory and prepare the structures so they can be called from other programs.
When issuing the API call LoadLibrary, Windows basically performs these tasks:
- Open the given file and check the DOS and PE headers.
- Try to allocate a memory block of PEHeader.OptionalHeader.SizeOfImage bytes at position PEHeader.OptionalHeader.ImageBase.
- Parse section headers and copy sections to their addresses. The destination address for each section, relative to the base of the allocated memory block, is stored in the VirtualAddress attribute of the IMAGE_SECTION_HEADER structure.
- If the allocated memory block differs from ImageBase, various references in the code and/or data sections must be adjusted. This is called Base relocation.
- The required imports for the library must be resolved by loading the corresponding libraries.
- The memory regions of the different sections must be protected depending on the section’s characteristics. Some sections are marked as discardable and therefore can be safely freed at this point. These sections normally contain temporary data that is only needed during the import, like the informations for the base relocation.
- Now the library is loaded completely. It must be notified about this by calling the entry point using the flag DLL_PROCESS_ATTACH.
Allocate memory
All memory required for the library must be reserved / allocated using VirtualAlloc, as Windows provides functions to protect these memory blocks. This is required to restrict access to the memory, like blocking write access to the code or constant data.
The OptionalHeader structure defines the size of the required memory block for the library. It must be reserved at the address specified by ImageBase if possible:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd4AAABlCAIAAABshhWWAAAKU0lEQVR4nO2d3aGzKhBFbz2py4bsxUIogy5yH+IPMHvQxCTOd7LWy8lBhHEk2wGN898NAACC8d/VBgAAQAvSDAAQDqQZACAcSDMAQDiQZgCAcCDNAADhQJoBAMKBNAMAhANpBgAIB9IMABAOpBkAIBxIMwBAOP6cNI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yI8wAPwPSHA9+cgLw8/zT0kyabQD4m/zT0gwA8DdBmgEAwoE0AwCEA2kGAAgH0gwAEA6kGQAgHEgzAEA4kGYAgHAgzQAA4UCaAQDCgTQDAITjf0cWhTVi2xdyAAAAAElFTkSuQmCC" alt="" />
If the reserved memory differs from the address given in ImageBase, base relocation as described below must be done.
Copy sections
Once the memory has been reserved, the file contents can be copied to the system. The section header must get evaluated in order to determine the position in the file and the target area in memory.
Before copying the data, the memory block must get committed:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZwAAABjCAIAAAAgkCEWAAAIyElEQVR4nO2d27XrKgxFbz2pyw3RC4VQBl34fsQPHksEJ9mOzZnz44xsYiNhKytAfKT/HgAAA/Hfrx0AAPgmiBoADAWiBgBDgagBwFAgagAwFIgaAAwFogYAQ4GoAcBQIGoAMBSIGgAMBaIGAEOBqAHAULREbfJxnoM7zReJC/OTpyPrn9FP69t/7uHkY+JB4dbqiHmkbnwHF57GXCjMfgU9og0ZDJeIkB/wx1F3q5jPT7lEhLyYqbnwhkNvndRg8iG9iu90/wWXRBcuBJ/7Zhv72IPJx62HSVj9CsaItjf/YFxvcordcwbnQi0Td4v5hsnzI0SJ2qrSc3C7Q5tMZzdg/04JzyO3c+dK6N8n/Tzv10h9mTzbop+ejpku7V8g2xnFgKowq++NC8Epfem7tdLS5mv03mf9Ztdg8mEdYjp+7Xx1jx7W3VQjksEgGtWVNw0pl3SjSd9HpX/s1ZU3ItmYd1eX3oV5jiFEHUzSz3J+f5OYv16E1KK2T26TqeO68slf74ObfJwT24firYobefDuU35YbWzycblAu3/6K0dMfJzbrnVxi4UqLRFSqlqHqE0+pjG1vJWsK8pv7/SEdIjZO8p5dY/03VQjMoJBNOZuLV0cCBsjlkx6gqx/7MaVN4303M3dZhW0hrcx+2DfI+avGCGVqGXjWC9nKUAx6b1WpL+Ybx5QELU267/BoRqk0UUSc+FFKFSNenHRum75Pkoe5ltv0vn6Hll3sx6REQyWJ+WVOBQ2OpYq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DdIGpXgodvAT7mpqJGiSkA0NxU1AAANIgaAAwFogYAQ4GoAcBQIGoAMBSIGgAMBaIGAEOBqAHAUCBqADAU/wPYtFTsGSdR2gAAAABJRU5ErkJggg==" alt="" />
Base relocation
All memory addresses in the code / data sections of a library are stored relative to the address defined by ImageBase in the OptionalHeader. If the library can’t be imported to this memory address, the references must get adjusted => relocated. The file format helps for this by storing informations about all these references in the base relocation table, which can be found in the directory entry 5 of the DataDirectory in the OptionalHeader.
This table consists of a series of this structure
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR4AAABaCAIAAADhFa5PAAAJCUlEQVR4nO2d7ZmsKhCEbzwTlwmZC4EQhlnM/aFCN12NONrzsafeH+eZZZRulQJkD7X/PQghAfz36QQI+ZtQWoSEQGkREgKlRUgIlBYhIVBahITwMWlNaXk+83xw1JyfG0ua3pJXIPVituuZ0qIubM7rj+XA5qJLeZ7nlKamxmfnfk5pQccdBlpyzhcCmTiyXBTq6kodMitROCedU3MHJdtX5s7jQHMun/czjppdpxn3pTXnw8Z/gePaL8WPSP6GOlUVU8rLsv0sP6/HpbUN7Ycu+3Oe0lJbQ334/eSmWtmURBwTSNY55/OB6pEijnP6pALv11ZuyP5RFJb+Bya/Vb1V29Su03YCiWcw8rA7x/jSgh3dWrhe2f455bUrWdoeCA45Uz2upoWOdHoa5wL3LPN+b1EvXbJfj8+z7HXkpalEl5TS+qBgz3+WVlop5a0TX/aP5TAlh7YRboetwx/8UuHV1QbSMnghkDi9Hu6cflSw3iw/qk0eVysq6wV6TCnvg2KgtJwTZUr7Zzkqls5V91N1yJXNfP0MjzxKHKYkezfn5DoJ20+DnWhNVPTcIaNWmuac50f9Rx4lE4KRRycuumfQY5YOJGsFPd1xoPoI9U1EpxsNNJe5fu/edZg8KrB1w0A63rulJQrLBz3B2NMDs96mWS3tnLu9+4MtWbQa/+ap7JyLnI46rBBp1W4G3domo3qtZax7YdQqPZAN1CRbDxwfteCTHBu1TknLTf6itI4ULU9b7pTW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W6WX3gq3DBBZF8M8o1Leldq3ZHThR5TD6kiY0GJwPpPyk4Omm0HhCaYPSoeTxK+WZxfenWH9XJlMUVgR3jlrk96CjUxj3/MqYENLwQ//RyUyzuvO3XwhE/jI/JC1CfglKi5AQKC1CQqC0CAmB0iIkBEqLkBD+B8HaSEee9btyAAAAAElFTkSuQmCC" alt="" />
It contains (SizeOfBlock – IMAGE_SIZEOF_BASE_RELOCATION) / 2 entries of 16 bits each. The upper 4 bits define the type of relocation, the lower 12 bits define the offset relative to the VirtualAddress.
The only types that seem to be used in DLLs are
- IMAGE_REL_BASED_ABSOLUTE
- No operation relocation. Used for padding.
- IMAGE_REL_BASED_HIGHLOW
- Add the delta between the ImageBase and the allocated memory block to the 32 bits found at the offset.
Resolve imports
The directory entry 1 of the DataDirectory in the OptionalHeader specifies a list of libraries to import symbols from. Each entry in this list is defined as follows:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnYAAAE3CAIAAACo2pv6AAAgAElEQVR4nO2d3aGrKhBGbyf3PSXcemyIXiiEMujC+6DIAAPiDzHJXuvhnMQgDAp8MOKef14AAABwK//999+///77z9NmAAAA/BpILAAAwBCQWAAAgCEgsQAAAENAYgEAAIaAxAIAAAwBiQUAABgCEgsAADCEZyR2sn6endlJZdy84u30FrsGEiuz1meyPqmYccvXLWFW6e24M8baKctxbl/P7tIn69Ust+PrOXq63KT6fVPPr9YoXhPnXMhTmGSss1PN9KLuleKrxvfVvUlfgweAX6MhscaNHBP2c79U/gjjb8gzyWKyzvv1u/y8pLPWRYGarA8j/mR9GOuNixrWY1xf6THVZJeDk/XzltJHQRQmBZVa0zs7bf/tWxNrp9ZIHDRurbuwY5seqCapdVerqRvfXfcmY/sSAHwqFYlNJ+rrwLIcjEPcPHtr3bKK8PW1g0+UIqSLg46WUlt51IjLO+c2RSiXGZv1S3pn5NpCVi0x1FtrlxFXy/MwuchZuxwwzoePWzKhUBWxWgb6HSU7XLpItWSdFRB+F8qXpeizSFoTzlBrJ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gc66WHlOFAFd7sd+3QFjrqesF2bkuSTmtGomDW9hcGTU3hgpWTFLrrlZTN7677gAAcIphEmvtcsA4Hz5uyUS2lRKWgb6/+L7SRaol66yA8LtQvixFn0XSmnCGWiMlylbzgqgpGhKbpk1PPFp345qLdwAAyBknsZNxzrziPzJVzLeyRA2uzd4h/VDp8WNWeiqHqx1qigPWmCD2ao0K53n1gtRMakpseV1qp+3WHYkFADjIQIldnuwlSrZ92DIOR+JTwG31eWkVq5Uun0kG92tFZmqPXK9IbLtGQdB25hyKyikSqz8y7pTYakEAAHCIvR3FxZqpnlBZLxkjH2Rq23MqzkvFg3q5dEWM9pylRe2vOoobtB/z1k1qrmK1EtRvHXUHAIBjjFzF5r+pSZJNNbrEdux36ihdzWhvy0++5+ewxDZrpNdSHhXbrWomnZXYg3XPN2oDAMAeN0hssTYNB7Y9u5LkoF/WbT79tXjJpLWc6ivdJ2++ZB7Syosr4n0bZzQza9csqXCrRtpLN1nq9BpmJu28tJPMOlTje+ve/wYXAABs3LaKhV9GvFoFAACd3PCnJwAAAKDkW/6AYuFp3XXY/kWTAADgg/gWiQUAAPgykFgAAIAhILEAAABDQGIBAACGgMQCAAAMYZHY/wG7mr92fPbIOgAAAABJRU5ErkJggg==" alt="" />
The Name entry describes the offset to the NULL-terminated string of the library name (e.g. KERNEL32.DLL). The OriginalFirstThunk entry points to a list of references to the function names to import from the external library. FirstThunk points to a list of addresses that gets filled with pointers to the imported symbols.
When we resolve the imports, we walk both lists in parallel, import the function defined by the name in the first list and store the pointer to the symbol in the second list:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkkAAAEICAIAAADEDvc3AAAfRElEQVR4nO2dUYKsKAxFZz2uyw2xFxfCMtyF86FCAglid1W1xTvnY6afpRAwcAlalf8mAACAsfjvrw0AAAB4MWgbAACMBtoGAACjgbYBAMBovF3b5mXdMjFcXxHiefa6zK80JcSjQMOm89C6zMU/8tn+1T9p57xE3bzqgGl8iC/vl0n0uV30vKx1m8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0xOsWlmFpWJSUWKUpHYuiwzxDPRaZWzM0QjjScAADyAL9W2aTq0aF3mlFFMJhnTf1dxmzik0pFVZU7zsh7SWaTkRNsAAJ7KV2tbrAMpQdKdW9pW5t0UR0jKCQDwHQykba70oG0AAP8WA2lbuWmYSPuTeX8xHQpRbSz2a1vevQQAgIfxpdqm9h+zwqg3R7LOpcP1mesSzjdLrDKPYzGkC45S52VF2QAAHsqXattfMy8rygYA8FTQNgAAGA20DQAARgNtAwCA0UDbAABgNNA2AAAYDbQNAABGA20DAIDRQNsAAGA00DYAABgNtA0AAEYDbQMAgNFA2wAAYDTQNgAAGI3PaBsZYQAA4HN8LG4jaTUAAHwItA0AAEYDbQMAgNFA2wAAYDQ++J5kiFsMn6sOAAD+VYjbAABgNNA2AAAYDbQNAABGg+9uAwDAaPCbWwAAMBpoGwAAjAbaBgAAo4G2AQDAaKBtAAAwGmgbAACMBtoGAACjgbYBAMBooG0AADAaaBsAAIwG2gYAAKOBtgEAwGjU2sbvGgMAwHdjxm3kowEAgC8GbQMAgNFA2wAAYDTQNgAAGA3nPckQtxg+awkAAMBrIG4DAIDRQNsAAGA00DYAABgNvrsNAACjwW9uAQDAaKBtAAAwGmgbAACMBtoGAACjgbYBAMBooG0AADAaaBsAAIzG/7116/F2mvqlAAAAAElFTkSuQmCC" alt="" />
Protect memory
Every section specifies permission flags in it’s Characteristics entry. These flags can be one or a combination of
- IMAGE_SCN_MEM_EXECUTE
- The section contains data that can be executed.
- IMAGE_SCN_MEM_READ
- The section contains data that is readable.
- IMAGE_SCN_MEM_WRITE
- The section contains data that is writeable.
These flags must get mapped to the protection flags
- PAGE_NOACCESS
- PAGE_WRITECOPY
- PAGE_READONLY
- PAGE_READWRITE
- PAGE_EXECUTE
- PAGE_EXECUTE_WRITECOPY
- PAGE_EXECUTE_READ
- PAGE_EXECUTE_READWRITE
Now, the function VirtualProtect can be used to limit access to the memory. If the program tries to access it in a unauthorized way, an exception gets raised by Windows.
In addition the section flags above, the following can be added:
- IMAGE_SCN_MEM_DISCARDABLE
- The data in this section can be freed after the import. Usually this is specified for relocation data.
- IMAGE_SCN_MEM_NOT_CACHED
- The data in this section must not get cached by Windows. Add the bit flag PAGE_NOCACHE to the protection flags above.
Notify library
The last thing to do is to call the DLL entry point (defined by AddressOfEntryPoint) and so notifying the library about being attached to a process.
The function at the entry point is defined as
typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
DllEntryProc entry = (DllEntryProc)(baseAddress + PEHeader->OptionalHeader.AddressOfEntryPoint);
(*entry)((HINSTANCE)baseAddress, DLL_PROCESS_ATTACH, 0);
Afterwards we can use the exported functions as with any normal library.
LoadLibrary执行的任务就到此结束了。
Exported functions
If you want to access the functions that are exported by the library, you need to find the entry point to a symbol, i.e. the name of the function to call.
The directory entry 0 of the DataDirectory in the OptionalHeader contains informations about the exported functions. It’s defined as follows:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbAAAAEdCAIAAADirqVNAAAW9klEQVR4nO3d3bmjOgyF4amHutIQvVCIy6CLzAUCS7ZkTP42JN97cZ49CcGGEMVAjte/AQAwDMMw/PvrDgDAWVAQAUBQEAFAUBABQHyoIN6m+X5P485SY7qLebp9pF9vlDdGtuc2zWbDxrT8c1uw2Ojt8TSO03Qr1nhv7U9vyeWxpY3l7zQO8s44q9wel175y5UNxe9b0E61lzob2lag+jlOSe/OsktHtmj5l/471nds4xp0QRzTO9/W/bU/1f47Ov+CdZpV3KY0z/Jv/fey3DSlXE5u07x+km/TvH6Gx5QrTrtz3pK3aWvwptvKa1qXuE3zfevn9mde57Ymeamszqy1tS/U1nnb4jQUbpGpZMv3i9el7i0yW7GzQW7ncWlrQbRfl/d8vK1fqOvfU1q+jOdySOEO7255uXzceEvWI4VYHjqltH1+6y/7rff5iz5/metNMx2dp2mqByoPjwDKgjhNywNjmtc/t8X2P4nLB7jnY+ovKYVoTGZ7VB+XFxQvW59XJalYoqtwmH1hXxEW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vw+tS9xb5U7QeMI5jno1z1G9wsZO9becI+YEj5Au8riBKLsAwpnn9c1tsfz8vb09/sk89o/osI47gI/lAvF+ju1Wfokmlw8NdLedsUXuuYxsNeGSL5OH++Y5tw3M99mjMYM4R4rZzySPk+WjDi3hhQVwCo/J/9FJVsEe9tr3zjt0lnfDtsfjYla3nuIA85fjdXWKvT+pFrWnS3YacLWoNgZqfp90tGtOc0iPlcF3/vAZAOD1wJ3pXHeMI2fnHaY8QCuIuJydim7J8e277o0rRyMONbdTwzPf/8sRcvI/V5OXhwRFdCHr54e4OsaotesHhHm3Rzvlm0xb/OJseeOPGsiGOkJ84Qi6vustcfgGG/GSmUV9e0YdbzsZwh/P9E7f7S8oJUesqlmnPPh/Fp73vhMgG+VZb9LoTovr9fPXhHq6PI8Rv5+eOkCt56QixfM5d5Oamd5q3vPmGeEuay8LqmnW9or0LzOUH5vDhHhx+dedzQ+626werSDd7DevYFgU75fEbiscKon2OI+RCR8gvnDE/VBCrb3U3V2xlHqx+XOCME/LDe23LkjnQbdB/6zw4e87QE+/nddNXbHB53cfZbtNQuO3qCfVZ9rrUu0X69erofqYe+juZIyTaSXrRax0hP1EOnxkh4lvUkciA8lS04cU88sNsfJXHfoMDfKPT/q971XnC7onJL3bpl53w7Thhl3DMaQsiAHwaBREABAURAAQFEQAEBREAxH/l9OVSXlL8lAAAAABJRU5ErkJggg==" alt="" />
First thing to do, is to map the name of the function to the ordinal number of the exported symbol. Therefore, just walk the arrays defined by AddressOfNames and AddressOfNameOrdinals parallel until you found the required name.
Now you can use the ordinal number to read the address by evaluating the n-th element of the AddressOfFunctions array.
Freeing the library
To free the custom loaded library, perform the steps
DllEntryProc entry = (DllEntryProc)(baseAddress + PEHeader->OptionalHeader.AddressOfEntryPoint);
(*entry)((HINSTANCE)baseAddress, DLL_PROCESS_ATTACH, 0);
- Free external libraries used to resolve imports.
- Free allocated memory.
MemoryModule
MemoryModule is a C-library that can be used to load a DLL from memory.
The interface is very similar to the standard methods for loading of lib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JOfLIy556mIfD9ri9ofcQd1VUz6cxrAj2+XY21RI4T8OShqhJCloKgRQpaCokYIWQqKGiFkKShqhJCl+B/5OGWoZxbTlQAAAABJRU5ErkJggg==" alt="" />
原文参考:
http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/
源码参考:
Load PE from memory(反取证)(未完)的更多相关文章
- Go web编程学习笔记——未完待续
1. 1).GOPATH设置 先设置自己的GOPATH,可以在本机中运行$PATH进行查看: userdeMacBook-Pro:~ user$ $GOPATH -bash: /Users/user/ ...
- [教程] [承風雅傳HSU]用ES4封裝Win7---ES4 Win7封裝教程(未完待續)
[教程] [承風雅傳HSU]用ES4封裝Win7---ES4 Win7封裝教程(未完待續) a10036it 发表于 2015-7-27 21:11:19 https://www.itsk.com/t ...
- 《MySQL 基础课程》笔记整理(进阶篇)(未完)
一.MySQL服务安装及命令使用 安装过程就不写了,毕竟百度经验一大把 MySQL 官方文档 MySQL 参考手册中文版 1.MySQL简介 RDBMS(Relational Database M ...
- ExtJs之Ext.grid.GridPanel(部分未完)
今天在家休息,年假不用就作费啊. 看了几部香港老电影,陪爸爸看了勇士占奇才, 然后,测试了一下EXTJS未完的内容, 在京东上订了七本历史普及书,近两百块..:) 搞定. <!DOCTYPE h ...
- Apple放大绝进行反取证
取证说穿了其实就是攻防,这本是正义与邪恶的对决,亦即执法单位与嫌疑犯两者之间的事,但现实生活中要比这复杂多了. 怎么说呢?举个例子大家便理解了.取证人员费尽心思,用尽各种手法,努力地想要自手机上提取重 ...
- javascript有用小功能总结(未完待续)
1)javascript让页面标题滚动效果 代码如下: <title>您好,欢迎访问我的博客</title> <script type="text/javasc ...
- ASP.NET MVC 系列随笔汇总[未完待续……]
ASP.NET MVC 系列随笔汇总[未完待续……] 为了方便大家浏览所以整理一下,有的系列篇幅中不是很全面以后会慢慢的补全的. 学前篇之: ASP.NET MVC学前篇之扩展方法.链式编程 ASP. ...
- 关于DOM的一些总结(未完待续......)
DOM 实例1:购物车实例(数量,小计和总计的变化) 这里主要是如何获取页面元素的节点: document.getElementById("...") cocument.query ...
- 我的SQL总结---未完待续
我的SQL总结---未完待续 版权声明:本文为博主原创文章,未经博主允许不得转载. 总结: 主要的SQL 语句: 数据操作(select, insert, delete, update) 访问控制(g ...
随机推荐
- nginx配置限制同一个ip的访问频率
1.在nginx.conf里的http{}里加上如下代码: limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $s ...
- 如何在IIS6,7中部署ASP.NET网站(转载)
查看web.config文件 web.config通常会放在网站的根目录,这个文件中包含了一最重要的网站运行参数.比如: connectionStrings,httpHandlers,httpModu ...
- SQL语句优化技术分析 整理他人的
一.操作符优化 1.IN 操作符 用IN写出来的SQL的优点是比较容易写及清晰易懂,这比较适合现代软件开发的风格.但是用IN的SQL性能总是比较低的,从Oracle执行的步骤来分析用IN的SQL与不用 ...
- bayboy下载安装
badboy是jmeter工具的好搭档. 好处体现在那里呢? JMeter是纯Java编写的软件功能和性.能测试工具,其录制脚本过于笨拙和复杂. 而Badboy是用C++开发的动态应用测试工具,其拥有 ...
- A*寻路算法 (cocos2d-js详细代码)
看了几天的A*算法,感觉要成为一个游戏开发者,有必要把这个著名的算法拿到手. 网上有此算法的代码片段,但主要还是些模板类的伪代码,所以想分享一段完整的A*算法代码供大家更好的理解!(这里使用的是js语 ...
- ionic 进入多级目录以后隐藏底部导航栏(tabs)(完美解决方案)
公司开始使用ionic开发项目,在此记录下把遇到的问题,网上有大牛已经把解决方法整出来了,不过记录在自己这里方便查阅. 这篇记录在有tabs的项目里,进入子层级时,底部导航还一直存在,本人是要让他只在 ...
- CSS3之动画Animation特效
CSS3的出现 让我们通过css样式也能写出炫酷的特效 通过 Animation 这个属性 无需插件和jquery也可以轻松的完成简单的动画效果 DEMO: <!DOCTYPE html> ...
- Spring 上传文件
最近碰到一个上传文件的需求,其实之前也做过但是都是search->copy 没有细究过,这次纯手工. 先看一下需要依赖的包: <dependency> <groupId> ...
- android中RelativeLayout无法填充ScrollView布局的问题
ScrollView是解决布局过长的情况下使用,一遍其下面会有个顶部布局,我项目里面是RelativeLayout,但是RelativeLayout无论设置 android:layout_height ...
- hdu 3666 THE MATRIX PROBLEM
差分约束系统. 根据题意,可以写出不等式 L <= (Xij * Ai) / Bj <= U 即 Ai/Bj<=U/Xij和Ai/Bj>=L/Xij 由于差分约束系统是减法.. ...