1

I don't know whether this is the right place to ask this question. I want some guide lines on this subject because I don't know how to search my problem in the internet.

I want to create an executable file which can inject code into a targeted (another) executable file and run that target. What I talking about is not a patched exe. I want that exe to inject the code and run the program.

Is it possible to create such executable files..? If it is, can you please tell me some guiding materials..?

ps: when I search about injection, I get only about dll injection and it is not I want.

Thank You!!

6
  • Search for code injection... You'll get dozens of articles and source code
    – EWD-0-
    Dec 19, 2017 at 13:30
  • code injection takes place at runtime, not before. Modifying a binary before it is executed = patching, which you said you are not interested in. I want that exe to inject the code and run the program - this does not make sense.
    – julian
    Dec 19, 2017 at 15:42
  • @SYS_V I might be using words incorrectly. But if you get the idea, I just want to make an exe (program 1) to run another exe (program 2) with my code injected. So if I delete program 2 and run program 1, it will not run properly.
    – Ramesh-X
    Dec 19, 2017 at 19:11
  • 1
    No, I don't get the idea. Do you understand conceptually how code injection works and what it means? Maybe you should explain why you are trying to do this.
    – julian
    Dec 19, 2017 at 19:47
  • @SYS_V we have two kinds of patching... in memory while execution and the file itself before execution. You have to make it clear what you mean by execution, 1. execution of the file or 2. execution of that particular instruction.
    – EWD-0-
    Dec 20, 2017 at 9:04

1 Answer 1

8

Start here--specifically, the third technique: "The CreateRemoteThread & WriteProcessMemory Technique". To quote:

Another way to copy some code to another process's address space and then execute it in the context of this process involves the use of remote threads and the WriteProcessMemory API. Instead of writing a separate DLL, you copy the code to the remote process directly now—via WriteProcessMemory—and start its execution with CreateRemoteThread.

You could also use the WriteProcessMemory function to write bytes directly, whether it's overwriting bytes directly or code-caving. There are nuances to keep in mind, though, like making sure the permissions of the memory you're writing to are set properly (read/write/execute), ala the Virtual* functions.

1
  • 1
    This was helpful, thanks!! And I was looking at your youtube channel. It is good.
    – Ramesh-X
    Dec 20, 2017 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.