Merge two exe files into one programmatically

那年仲夏 提交于 2019-11-30 08:32:42

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.

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.

You can create your own EXE file that contains two other EXE files as embedded resources and extracts and executes each of them.

Beware that the EXE that you embed might not work if you extract it to a different directory.

Technically it is possible to embed some other exes files in your exe, some packers like upx do it. So you should be able to do the same with 2 exes.

In a unix like fashion your exe could fork, then the first process execute the first old executable, and the new process execute the second exe, maybe installing a pipe between them before.

But this is clearly not so easy to do and very probably a useless overkill for your needs. You probably just need a small .bat or .sh

I noticed your "programmatically" qualifier, but just in case an out-of-code solution is acceptable for whatever you're doing...

IExpress can build an EXE which executes two other EXEs. You can build an IExpress package from the commandline.

SED file:

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=1
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
TargetName=C:\combined.exe
FriendlyName=Example Title
AppLaunched=run.bat
PostInstallCmd=
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="FirstProgram.exe"
FILE1="SecondProgram.exe"
FILE2="run.bat"
[SourceFiles]
SourceFiles0=C:\programs\
[SourceFiles0]
%FILE0%=
%FILE1%=
%FILE2%=

run.bat file:

FIRSTP~1.EXE
SECOND~1.EXE

When you run combined.exe, firstProgram.exe will execute. When it's finished, secondProgram.exe will execute. If you wanted firstProgram.exe and secondProgram.exe to run concurrently, it could be done with a change to the BAT file.

Copy data from 1 file to third one Remember the position of the eof. Add binary from second file to third. Then add at the end number (in int) of eof value. In first file should be a code which could copy whole file from this value at the end to the end of file to another file.

And execute.

It's easy way to do it.

This was how I wrote my virus in c++ System("type virus.exe >> not_virus.exe") but if you are doing it via command prompt then simply do this. Type virus.exe >> not_virus.exe But I am looking forward to a way I can prepend it rather than appending by asking it to first goto first line then copy its code into the victim executable file

No it is not possible to "inject" one exe into another. This action is not even defined as you don't have the control over the execution internals that you do when you inject objects into one another.

The closest thing possible with exe files is piping, where you can redirect the output of one exe file to the input of another one:

one.exe | two.exe
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!