InfectPE – Inject Custom Code into PE File

April 29, 2017 | Views: 2550

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Using this tool you can inject x-code/shellcode into PE file. InjectPE works only with 32-bit executable files.

Why you need InjectPE?

  • You can test your security products.
  • Use in a phishing campaign.
  • Learn how PE injection works.
  • …and so on.

In the project, there is hardcoded x-code of MessageBoxA, you can change it.


Windows x86 binary – Hardcoded MessageBoxA x-code, only for demos.


vc_redist.x86 – Microsoft Visual C++ Redistributable


.InfectPE.exe .input.exe .out.exe code

X-code is injected into code section, this method is more stealthy, but sometimes there is no enough space in the code section.

.InfectPE.exe .input.exe .out.exe largest

X-code is injected into a section with the largest number of zeros, using this method you can inject bigger x-code. This method modifies characteristics of the section and is a bit more suspicious.

.InfectPE.exe .input.exe .out.exe resize

Expand the size of code section and inject x-code. This technique, like “code” one, is less suspicious, also you can inject much bigger x-code.

In the patched file, ASLR and NX are disabled, for the more technical information you can analyze VS project.

Please, don’t use with packed or malformed executables.


Vimeo – “code” and “largest” techniques.

Vimeo – “resize” technique.


Add more techniques to inject x-code into PE file.

Download InfectPE

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge


We recommend always using caution when following any link

Are you sure you want to continue?