PHP / C ++: entering values ​​into an exe file

I would like to add value to an exe file on the fly.

The company I dealt with in the past provided me with an EXE stub that I can use PHP to enter values ​​on the fly before the user loads it.

I can’t find anything on Google, since I don’t know the name of this process, can someone point me in the right direction? Ideally, this would be C ++ / PHP, but it can be flexible, or even just information about the general process of how this will work will be a great start.

They even did it with the EXE that they sent me, I signed with my certificate, then they “populated” the file, and I was able to insert the values ​​on the fly.

Unfortunately, they will not tell me their secrets ...

+5
source share
1 answer

I can offer several different approaches:

  • Include a magic line in an executable file, for example. static const char magic[] = "magic marker goes here"' . You will have to reference this from another place in your code so that it is not optimized. Then you can open .exe from php and find the magic line and overwrite it with any desire within the limit.
  • If you want to insert multiple values, a more structured approach is to use PE resources in the executable. There is a good Python module for analyzing PE resources , maybe there is a PHP equivalent.
  • Changing anything in the executable will break any codes. One thing that is excluded from the authentication hash is the PE checksum (explanation here ). The PE checksum has a fixed offset in the executable, so you can find it in your PHP script and fix it whatever you like. Correcting this value will not violate the signature of authenticity.
+2
source

Source: https://habr.com/ru/post/1200108/


All Articles