Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2005, 23:18
jonwil jonwil is offline
VIP
 
Join Date: Feb 2004
Posts: 387
Rept. Given: 2
Rept. Rcvd 21 Times in 9 Posts
Thanks Given: 2
Thanks Rcvd at 65 Times in 34 Posts
jonwil Reputation: 21
How to inject code into a process?

I am looking for a way to inject code into an already running process and have it run (it would read memory space of the process, call code of the process etc)

Or if that cant be done, is theree a way to get the process to load my DLL instead of some system dll so that my DLL can sit there and wait for a signal (e.g. external signal sent to say that it can

Note that changing the on-disk representation of the process is not an option (i.e. I cant modify the process exe file on disk).

This is for a program that would load into the memory space of a running Trymedia app and (by calling the trymedia functions in the exe file) decrypt protected resource files. You would change parameters in the code or in a config file (e.g. filename of protected resource file, output filename, size, location within the memory space of the protected exe file for redirected CreateFileA/ReadFile and so on) and then build the dumper.
Then you load the target and wait untill you get to a point where it has to have read the desired data file (i.e. let it get into the game)
Then you would run or trigger the code that was loaded into the process memory space which would read in the protected resource file via the trymedia hooks and write it out to disk in unencrypted form.

With this, you wouldnt need a debugger or debugger-hider. Or any messing about with breakpoints or runtime patching. All you would need to do is to find the location within the .bss segment of the needed AM functions for the AM version you are cracking, it would really only need CreateFileA and ReadFile redirects I think. It could even be run by someone who has an unlocked copy of the program in question (someone who doesnt have any reverse engineering skills)

In fact, if one was to build up a database linking AM version to location of needed hooks, one could make it even easier to use
Reply With Quote
  #2  
Old 05-27-2005, 23:54
Spiteful
 
Posts: n/a
hm, I've written small app to inject my dll into a running process... maybe it will help you
Specify dll, then choose running process from the list and in context menu - > 'Inject dll'
P.S. Executable to inj... just to start process simultaneously with injecting
Attached Files
File Type: zip injektor.zip (3.3 KB, 36 views)
Reply With Quote
  #3  
Old 05-28-2005, 02:14
FEARHQ FEARHQ is offline
Friend
 
Join Date: Mar 2002
Posts: 73
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 1 Time in 1 Post
FEARHQ Reputation: 0
Well, there are a couple of ways you can inject code into a foreign process. One of them is to get the process ID of the target, however you may wish to do that, OpenProcess, find a 'cave' where you can write a bit of code to, GetClassLong to get WinProc's address, WriteProcessMemory some code that will load your dll into the process address space into the cave, save the bytes at the begining of WinProc and replace them with a jump to your cave, then restore them after you're done loading the dll. Mind you instead of stealing WinProc for a second, you can also just write the cave and use CreateRemoteThread (not sure of exact name) to start a remote thread you have written into a cave, or you can emulate one of the dll's the process uses, making sure to provide ALL the imports the process needs with the proper ordinals and simply jam it into the executable root directory. The first method described was used by D2hackit, whose source is freely available. You might also want to check out code injection at the old fravia mirror at woodmann's site and ofcourse microsoft Detours.
Reply With Quote
  #4  
Old 05-28-2005, 14:47
nikola nikola is offline
Friend
 
Join Date: Jan 2004
Location: Your head
Posts: 115
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 1 Time in 1 Post
nikola Reputation: 0
jonwil, i think you should read about some APIs.
ReadProcessMemory, WriteProcessMemory, VirtualAllocEx, CreateRemoteThread Tho CreateRemoteThread exists only on NT systems.
Reply With Quote
  #5  
Old 05-28-2005, 21:12
Shub-Nigurrath's Avatar
Shub-Nigurrath Shub-Nigurrath is offline
VIP
 
Join Date: Mar 2004
Location: Obscure Kadath
Posts: 919
Rept. Given: 60
Rept. Rcvd 419 Times in 94 Posts
Thanks Given: 68
Thanks Rcvd at 330 Times in 100 Posts
Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499 Shub-Nigurrath Reputation: 400-499
there's also a thread here where a number of alternative methods, working also on Win9x system, has been proposed..MaRKuS-DJM were the thread starter..

http://www.exetools.com/forum/showthread.php?t=7211

read posts you-ll find some useful links I think.
__________________
Ŝħůb-Ňìĝùŕřaŧħ ₪)
There are only 10 types of people in the world: Those who understand binary, and those who don't
http://www.accessroot.com

Last edited by Shub-Nigurrath; 05-28-2005 at 21:16.
Reply With Quote
  #6  
Old 06-01-2005, 19:29
NeOXOeN NeOXOeN is offline
Friend
 
Join Date: Jan 2005
Posts: 273
Rept. Given: 2
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 2
Thanks Rcvd at 18 Times in 18 Posts
NeOXOeN Reputation: 3
jonwil i know you are VIP member but i think you should you search option avalible on this forum more often!Like Shub-Nigurrath suggested that link above was one of my first hits i got using the same words as you used in topic..



bye NeO
Reply With Quote
  #7  
Old 06-01-2005, 22:03
JMI JMI is offline
Leader
 
Join Date: Jan 2002
Posts: 1,627
Rept. Given: 5
Rept. Rcvd 199 Times in 99 Posts
Thanks Given: 0
Thanks Rcvd at 96 Times in 94 Posts
JMI Reputation: 100-199 JMI Reputation: 100-199
Oh NO! Not SEARCHING! Who'd a thunk it?

Regards,
__________________
JMI
Reply With Quote
  #8  
Old 06-01-2005, 23:23
bEaST
 
Posts: n/a
Quote:
Originally Posted by jonwil
I am looking for a way to inject code into an already running process [...]
Here some article that should help you. Hopefully you can code in C(++)!

Take a look at this article, it's one of the best I found...
Three Ways to Inject Your Code into Another Process
http://www.codeproject.com/threads/winspy.asp

Also interesting (not read)
Extending Task Manager with DLL Injection
http://www.codeproject.com/threads/taskex.asp

Good luck...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Easy way to Inject a Dll Rhodium General Discussion 9 10-28-2004 16:52


All times are GMT +8. The time now is 11:48.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2024 )