A
A
Andrew2013-11-15 22:26:43
C++ / C#
Andrew, 2013-11-15 22:26:43

Passing a variable to an exe file when downloading it?

Hello.
There is a link site.ru/download/?name=Laptinius By going
to this page, an .exe file (C#/C++) with the string name = "Laptinius" variable inside should be downloaded.
How can this be implemented? To generate exe'shnik at request or in some way to register the given variable in properties?
Please help.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
Hint, 2013-11-15
@Laptinius

Append a line to the end of the binary, and then read it at startup. You do not need to change the CRC or understand the structure of the PE file.
Rough PHP script example:

header('Content-Type: application/octet-stream');
readfile('file.exe');
echo chr(0) . $_GET['name'];

Don't forget to add other important headers (Content-Length, etc.).
In the program, you need to open your file for reading, go to the end, find the first zero and read the line.

A
afiskon, 2013-11-16
@afiskon

If I understand correctly, do I need to replace Laptinius with something else? Then it's very easy to do. Open the exe with some hex editor and find the offset of this line. Before downloading, create a copy of this file and write another line at this offset.
Or, so that there are no problems with updating the exe file, use not an offset, but scan the file in search of this line. It will be very good if the string is long and unique, like Wai3AhKukaiQuai1.

B
bogolt, 2013-11-23
@bogolt

In the body of the program, add a buffer that will store the value injected during download, for example:
volatile char external_buffer[MAX_LEN] = {0};
When downloading, insert the necessary data into the exe body (there are two options, either find out the offset of the allocated buffer, or search by its unique value).
The program itself can simply use the value of the variable.

V
Vladimir Polishchuk, 2013-11-15
@NorthDakota

This is not possible without "recompiling" the file. Unless to collect a file on the fly + .manifest

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question