Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge two exe files into one programmatically

Is there a way to merge two exe files into one, programmatically, so that running it would execute both older exe files together. I found some things on google about injecting code or dll files but is it possible two merge two exe files or to inject exe into exe?

Thanks in advance.

[EDIT] Thanks everyone. Just for those who said that it's not possible, I have to say I almost did it in the end in the way some suggested. It almost goes like this (I can't remember all of it cos it was a long time ago):

[BEWARE: This algorithm is very similar to those of some worms and viruses. I am not a hacker or a virus writer! and this is to be used only for experimental or unharmful reasons - Making mistakes in the code can ruin the executables in directories.]

1- The Exe checks itself's size to detect whether anything has been appended to itself. if it hasn't then:

     1.1- The exe finds other executable files in its directory (lets call one of them as victim!)
     1.2- it makes a copy of itself (lets call it newMe)
     1.3- it copies the other executable found in the directory to the end of newMe.
     1.4- it deletes the other executable file found and renames newMe to its victim's name.

2- If the exe detects that something has been added to it then:

     2.1- Then it copies data from itself (from ORIGINAL_FILE_SIZE to the end of file) to a new file (lets call it newBorn.exe)
     2.2- It runs itself's code and then executes the newBorn.

I said I ALMOST did it cos in this way the exe appends another exe to itself. but this could be repeated for appending and executing 2 or even 3 or more executables into one. you just have to know the ORIGINAL_FILE_SIZE of the written program.

like image 658
Auxiliary Avatar asked Feb 15 '10 19:02

Auxiliary


People also ask

Which tool can bind multiple executable files together?

Binding Multiple Executable Files Certain tools, such as the WinZip Self-Extractor, nBinder, or File Joiner can create one executable file by archiving all related files whose execution will be controlled by a stub executable.

How do I merge two programs together?

The easiest way is to use a batch file. And run one after the other. Another way is to create a third exe and add the first two as resources to it. At run time, write the resources to a folder and run one after the other.


2 Answers

Theoretically this is possible, but it will take some effort from your side.

You can append data to an exe file, this is how self extracting archives work. However, you'll need your own data format, similar to a file system, because you've got just one flat .exe file.
See this Microsoft article (there's a lot more on google) http://support.microsoft.com/?scid=kb%3Ben-us%3B84062&x=12&y=13

The exe you're packing your two files in must then extract those files and can finally run them.

Good luck.

like image 141
svens Avatar answered Sep 20 '22 09:09

svens


No, your best bet is to create a .bat file (Windows) that runs both executable files.

@echo off
c:\path\to\first\exe\file1.exe
c:\path\to\second\exe\file2.exe

You can also create a shell script in Linux to do the same thing

#!/bin/sh
/path/to/first/exe/file1
/path/to/second/exe/file2

Note, this will execute file1 before file2.

like image 40
Robert Greiner Avatar answered Sep 20 '22 09:09

Robert Greiner