I have an installation file developed with c #, when my customers download and install this file from my website, I cannot understand which customers are using this exe. I have one setup file but I have 100 clients. I have to keep the customer's ID somewhere while downloading the setup file and show it to my application during the setup phase. I could not find how to do it.
-
related: https://stackoverflow.com/questions/32164471/how-to-download-msi-installer-with-argument-for-user-id – Daniel A. White Feb 23 '21 at 18:47
-
You could have customers add a environmental variable with there ID that application can read. – jdweng Feb 23 '21 at 18:51
1 Answers
You can do this by injecting the customer ID into the executable itself at the moment that the customer is downloading the executable and you know the customer ID. If you append the customer ID data to the end of the executable, then on startup of the executable you can have the executable read itself and parse the customer ID from its own binary. This will not cause any changes to the behavior of the executable.
However if your executable is signed, doing this will invalidate the certificate. To mitigate this, you can modify the headers of the executable and adjust some values to take into account the new size of the binary.
The specific changes necessary are:
- Locate beginning of PE header (PE)
- Skip COFF header (+=28 bytes)
- Go to Certification Table Entry in the Windows specific optional PE header (+=120 bytes after COFF; total +=148 bytes)
- Change size of Certificate Table as defined in IMAGE_DATA_DIRECTORY.Size to add the size of the payload.
- Go to location defined IMAGE_DATA_DIRECTORY.VirtualAddress. This is the absolute location of the Certificate Table within the file.
- Change again the size of the header, inside the PKCS1_MODULE_SIGN.dwLength
- This should normally be the last section in the executable; so go to the end and add payload
- Possibly calculate the new checksum of the file
Source for how to modify the executable without invalidating the signature: https://blog.barthe.ph/2009/02/22/change-signed-executable/

- 1