views:

49

answers:

4

Let's say I write a game application. I want the level of the player to be stored in an external file.

How can I prevent a hacker from writing and modifying the file to put another level ? I want the file to be modified by my application only.

I can sign the file's content with a key, but then this key will be stored in the application, therefore it would be possible for a hacker to decompile the binary and find the key.

Is there any way to do this ?

A: 

One easy way would be to start with a checksum. Calculate the checksum when you modify the file and persist it. When you need to check authenticity, re-calculate the checksum and compare it to the value you've stored. It's not a 100% guarantee, but it's simple and might be enough for your needs.

duffymo
But in this case it would be really easy for hacker to put his own values, calculate the checksum and put it in the file.
Ale_x
+2  A: 

No, there just isn't a secure way to do this. Whatever your application can do, an attacker can always replicate.

If its just a desktop game, you can get away with security through obscurity. But if it must be secure, the only way out is to store that information on your servers.

sri
So I'm assuming that's how most PC games currently do ?Any advice on how to add as much obscurity as possible ?
Ale_x
See the accepted answer to this question for ideas - http://stackoverflow.com/questions/73947/what-is-the-best-way-to-stop-people-hacking-the-php-based-highscore-table-of-a-f
sri
A: 

You can use hash algorithms with a symmetric key or public/private key pairs. you can check MAC (message authentication code) to get an idea, these methods will provide integrity and with a key authentication of the file.

alt text

berkay
It doesn't solve the problem of where to store the K key in a secure way.
Ale_x
@Ale_x use this method, find a way to store the key securely.
berkay
A: 

In addition to what everyone else has said, you should also consider the fact that as long as the application is loaded in the computer's memory, there's nothing stopping someone from simply modifying the level ( or any other value for that matter ) by just scanning the memory until they find the value they need and then replace it, so you should probably consider checking for abnormal increases in any value.

kiwi