Jump to content

  • Log In with Google      Sign In   
  • Create Account


Make file unreadable by an external program

  • You cannot reply to this topic
21 replies to this topic

#1 Reakbyz   Members   -  Reputation: 117

Like
0Likes
Like

Posted 28 July 2014 - 08:00 AM

Hi,
 
As mentionned in the title, I want to make my resources files (text, images and audio) of my game unreadable from external programs like Word, Photoshop or VLC Media Player...
 
I don't want to make an encryption/decryption algorithm that requires to create a output file (because it could be read easily) or something stored in the memory (don't want to take to much pc resources you see ?). I just want to make them directly readable in SFML through a c++ algorithm, i'm not looking for an extremely complicated process.
 
I saw how resources files were crypted for Terraria (XNB Files) and if you could tell how it works it would be great ^^
 
Thanks for your replies


Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 3895

Like
5Likes
Like

Posted 28 July 2014 - 08:23 AM

I find it highly unlikely that Terraria encrypts its files. According to 30 seconds of Googling, it just appears to be a custom format, most likely to make loading and streaming easier. That's not encryption and any user with a bit of technical background can get access to the data even if the specification is not public for easier modding.

If you want to prevent casual opening/modifications of your resources give them a non-standard extension (like .myimage instead of .png). That should prevent opening them by simple double-click in Windows. Of course even a user with a minimum of technical understanding can still just drag the file into Gimp.
Alternatively just store multiple files inside some archive format. I would advise against encryption. It will most likely cause you more problems getting it right than a skilled user to grab the decryption keys from your own executable.

#3 SmkViper   Members   -  Reputation: 654

Like
2Likes
Like

Posted 28 July 2014 - 08:37 AM

Encryption will also slow down your game loader - not much of an issue in a small project, but for a large game it's definitely noticeable. Released games are more concerned about loading something fast then encrypting it - it just so happens that the kinds of things you do to make something load fast, like archiving them, using a custom format, or preprocessing also make them difficult to read by standard programs.

#4 Jan2go   Members   -  Reputation: 703

Like
5Likes
Like

Posted 28 July 2014 - 08:44 AM

XNBs are simply files that are generated by the XNA Content Pipeline. They are not encrypted in any way, you can write yourself a viewer without much trouble using XNA or Monogame.

The easiest way that I can think of to "protect" your assets would be to store them in one or multiple archive (7z, zip, ...) and use a custom extension. Then, you change the the archive header so that the files cannot be opened without knowing how to reconstruct the original header.

Somehow I wonder what kind of assets you have that no one must be able to see them. biggrin.png

#5 SeanMiddleditch   Members   -  Reputation: 5117

Like
14Likes
Like

Posted 28 July 2014 - 11:13 AM

And the best approach of all is to just not worry about it and do what makes the game better. Pirates and copyright thieves are going to pirate and steal. You can't stop them. Spend your time and energy doing something more useful like make your game better.

#6 Reakbyz   Members   -  Reputation: 117

Like
0Likes
Like

Posted 28 July 2014 - 01:12 PM

Thank for your replies

 

 

I find it highly unlikely that Terraria encrypts its files. According to 30 seconds of Googling, it just appears to be a custom format, most likely to make loading and streaming easier. That's not encryption and any user with a bit of technical background can get access to the data even if the specification is not public for easier modding.

If you want to prevent casual opening/modifications of your resources give them a non-standard extension (like .myimage instead of .png). That should prevent opening them by simple double-click in Windows. Of course even a user with a minimum of technical understanding can still just drag the file into Gimp.
Alternatively just store multiple files inside some archive format. I would advise against encryption. It will most likely cause you more problems getting it right than a skilled user to grab the decryption keys from your own executable.

 

I had also the same idea about the custom file extension but that is not enough

 

Encryption will also slow down your game loader - not much of an issue in a small project, but for a large game it's definitely noticeable. Released games are more concerned about loading something fast then encrypting it - it just so happens that the kinds of things you do to make something load fast, like archiving them, using a custom format, or preprocessing also make them difficult to read by standard programs.

 

Ok so i give up the encryption method

 

XNBs are simply files that are generated by the XNA Content Pipeline. They are not encrypted in any way, you can write yourself a viewer without much trouble using XNA or Monogame.

The easiest way that I can think of to "protect" your assets would be to store them in one or multiple archive (7z, zip, ...) and use a custom extension. Then, you change the the archive header so that the files cannot be opened without knowing how to reconstruct the original header.

Somehow I wonder what kind of assets you have that no one must be able to see them. biggrin.png

 

But zipping file will not make them slower to read ?



#7 Haytil   Members   -  Reputation: 381

Like
1Likes
Like

Posted 28 July 2014 - 01:19 PM

But zipping file will not make them slower to read ?


It will make them slower to read.

#8 SeanMiddleditch   Members   -  Reputation: 5117

Like
5Likes
Like

Posted 28 July 2014 - 01:27 PM

But zipping file will not make them slower to read ?

It will make them slower to read.

This is not necessarily true. Poor usage can be slower, but typically on modern machines disk access is far slower than CPI decompression time for small-to-medium files. Random access of many small files is also typically dslow. This is why so many games do just zip up all assets into one big pack (though not necessarily as the pkZip format). Also remember that you can compress (or not compress) individual files if you have done metric indicating that compression will slow down access (e.g for large files that are already compressed, like PNG images).

#9 Chris_F   Members   -  Reputation: 2233

Like
4Likes
Like

Posted 28 July 2014 - 02:57 PM


I had also the same idea about the custom file extension but that is not enough

 

Why not? What are you trying to prevent?

 

The reality check is that no matter how much effort you put into it, people will be able to undo whatever it is you come up with, so you might as well not waste much of your time with it. I'm sure it could be better spent improving other, more important aspects of your game.



#10 Jan2go   Members   -  Reputation: 703

Like
0Likes
Like

Posted 28 July 2014 - 03:23 PM

But zipping file will not make them slower to read ?


As Sean already said, the decompression will be faster than the IO most of the time. If for some reason you are slowed down by the decompression you can always take a compression algorithm that favors speed over compression ratio (e.g. LZ4).

#11 BedderDanu   Members   -  Reputation: 245

Like
0Likes
Like

Posted 28 July 2014 - 06:13 PM

For what it's worth, Microsoft uses regular old zipped XML files for it's office documents (.???x files, like .docx). If you convert them from docx to zip, you can extract the XML and see what makes them up.

 

Almost everyone has no idea they are multi-file zip archives, and opening them takes almost no time, even for large files.

 

So if you name them "Tank.content"; which is really Tank.zip; which is an archive that contains Tank.obj, Tank.png, and Tank.wav; then you have already deterred most everyone from opening them up and seeing what's inside.



#12 dgcoventry   Members   -  Reputation: 145

Like
0Likes
Like

Posted 29 July 2014 - 05:36 AM

You could try aligning the bytes of the files so that they're not on a byte boundary.



#13 jhunt1   Members   -  Reputation: 123

Like
0Likes
Like

Posted 29 July 2014 - 06:32 AM

It's common to either put content in Zip files or store your content as blobs in a SQLite database.

#14 Ohforf sake   Members   -  Reputation: 1798

Like
5Likes
Like

Posted 29 July 2014 - 08:43 AM

You can obfuscate, bitshift, encrypt, hide the keys, decrypt in a custom VM and download secondary keys from a remote server all you want.

As soon, as the game has loaded, literally all I need to do is Alt-Tab out to Pix/gDebugger/ApiTrace/... select the texture and click "Save As...".

It simply doesn't matter what you do to your content, as long as you pass it into an API call somewhere down the line, that will always be the weak spot.

#15 NathanRunge   Members   -  Reputation: 420

Like
1Likes
Like

Posted 29 July 2014 - 08:52 AM

Chris hit it on the head, the question is: why? The answer to your question entirely depends on your answer to that question.


Personal Page: http://www.nathanrunge.com/     Company Page: http://www.ozymandias.com.au/


#16 Joshhua5   Members   -  Reputation: 436

Like
0Likes
Like

Posted 29 July 2014 - 09:05 AM

Prison Architect is also just a compressed file with a different name, you can extract it with 7Zip and view all the game files. there's shaders and lua scripts in there.



#17 stupid_programmer   Members   -  Reputation: 1087

Like
3Likes
Like

Posted 29 July 2014 - 09:30 AM

You can obfuscate, bitshift, encrypt, hide the keys, decrypt in a custom VM and download secondary keys from a remote server all you want.

As soon, as the game has loaded, literally all I need to do is Alt-Tab out to Pix/gDebugger/ApiTrace/... select the texture and click "Save As...".

It simply doesn't matter what you do to your content, as long as you pass it into an API call somewhere down the line, that will always be the weak spot.

 

Quote this one again for truth.  If people want to steal your assets they will steal your assets.  There is nothing you can do to prevent that.  If multi billion dollar companies are using plain old zip (which is probably more for file size on disk and not encryption) then why are you worrying about this so much?  Spend your time on something more important.



#18 Reakbyz   Members   -  Reputation: 117

Like
1Likes
Like

Posted 30 July 2014 - 07:59 AM

I'm looking for a simple process to make my files unaccessible from random people a look at as they wish. Just to discourage dumb people to do it you see ?

 

I think a would try compression with a minimum compression ratio, thank you guys for your precise answers.

 

 

As soon, as the game has loaded, literally all I need to do is Alt-Tab out to Pix/gDebugger/ApiTrace/... select the texture and click "Save As...".

 

 

I'm did not understand this line, could you tell me more about it please ? If you agree ^^


Edited by Reakbyz, 30 July 2014 - 08:04 AM.


#19 GoCatGo   GDNet+   -  Reputation: 1619

Like
0Likes
Like

Posted 30 July 2014 - 08:45 AM


Just to discourage dumb people to do it you see ?

 

Dumb people won't try.  Smart people will look at the files no matter what you do.


I don't even like games anymore.


#20 Reakbyz   Members   -  Reputation: 117

Like
0Likes
Like

Posted 30 July 2014 - 10:22 AM

Yes but dumb people who are at ease on computer and could change audio files of a game for exemple







PARTNERS