I would be interested in whether it is possible in some way to check my application against modifications by checking its checksum.
So, for example:
int main()
{
const std::string checksum = "98123abc1239";
std::string myChecksum = calculateChecksumOfThisApp();
if(checksum != myChecksum)
std::cerr << "This application is invalid. Please check if the download has been successful." << std::endl;
}
Clearly, the issue here is that compiling my application, getting the executable's checksum and inserting it into my checksum
changes the checksum of the application.
I could store the checksum externally in some file, but I would like to have the side-benefit of others not being able to manipulate the exe. They could just calculate the checksum once again and put it into the checksum file, so nothing would be gained from that.
Is there any way to create such a self-check?
The easiest workaround is to make the checksumming routine aware of the position where the checksum itself is stored, and skip the bytes when calculating the checksum.
If calculating the position is too much hassle, you can prefix the checksum with a magic string and recognize that. Just make sure that the checksumming procedure doesn't store the magic string literally, as you don't want to escape that copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With