|
-
February 8th, 2012, 03:19 AM
#13
Re: [Help/Advice needed]Program crashes when code is injected
Great. Now we can start a discussion.
1. Initialize the DLL function via LoadLibrary & GetProcAddress.
I'd like to understand what 'initialize' actually means. And what 'the DLL function' is.
3. Allocate memory space for the DLL codes to be executed in there via VirtualAllocEx.
4. Write the code to be executed into the memory space allocated via WriteProcessMemory.
This won't work. You need to load the dll to the target process. Loading dll is much more than just copying code.
Okay, here's an alternative plan:
1. Implement thread procedure that would be copied to target process:- The thread initially loads the dll to target process by calling LoadLibrary.
- !! LoadLibrary needs dll full path be copied to target process address space
- Optionally, thread locates initialization function in the dll in context of target process by GetProcAddress
- !! GetProcAddress needs initialization function name be copied to target process address space
- Call the located initialization function
- Optionally, unload the dll if required
- Quit
2. Allocate memory enough for keeping dll path and initialization function name. These data may comprise a struct type.
3. Fill the sample data structure on injector side
4. Copy the data structure to target process
5. Locate the bounds of implemented thread function in injector process
6. Allocate space for thread function in target process (here PAGE_EXECUTE is needed)
7. Copy thread function bytes to target process
8. Create remote thread providing remote thread function address as a thread routine, and remote data structure address as a thread parameter
9. Wait on thread handle until the thread quits
10. Free remote memory, both data struct and thread code
Last edited by Igor Vartanov; February 8th, 2012 at 03:32 AM.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|