Protecting Files

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Protecting Files

#1 Post by Kaen »

So far I'm using the archive resource to protect my files:

Code: Select all

build.classify("game/**", "archive")
Though I'd like to know if there is a way to protect the game files better so it's more difficult to gain access to them (specially the image files).

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Protecting Files

#2 Post by xela »

None that would be useful to you.
Like what we're doing? Support us at:
Image

User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Re: Protecting Files

#3 Post by Kaen »

What do you mean xela? Feel free to share if you want.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Protecting Files

#4 Post by Asceai »

You're fighting a losing battle. Once the files are on someone's machine, they can and will be able to gain access to them. You can't make it possible for the game to open them but not possible for anyone else.

Anyway, for protecting image files specifically, I guess I'd suggest this process (note that none of this code is available and I'm not writing it, but so you're aware of what's involved...):
- Create a missing image handler to replace image access in your application. This is the way JCC works
- Determine a way to construct a series of steps to obscure the image that can be reconstructed using image manipulators. This will slow down image loading in your game
- I'd suggest the process for obscuring images would be to first seed a random.Random instance using the image path as seed.
- Then you could try splitting images in a deterministic way that works in all cases, possibly decided by the random number generator. You might just decide to split all images above a certain size into a grid of images, with one randomly-selected image being unusually tall / short / wide / thin. Then shuffle the images, again using the random number generator, apply undoable image manipulator transforms like flip, matrix operations etc., creating randomly-generated filenames for these images and then dumping them in the directory.
- Note that you can't save images from Ren'Py, so I'd suggest writing a separate tool in pillow to do the obfuscation and using the image manipulators in your Ren'Py game to reverse the task.
- Then you just need to do the same stuff, but in the opposite order in your game when loading images using the missing image handler.
- Once your game is filled with these garbage-named files that are scrambled, miscoloured and flipped chunks of images not really useful to anyone, you can exclude the original images from distribution

That will only make things very slightly harder for anyone to attack. Like I said, losing battle.

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: Protecting Files

#5 Post by LVUER »

No reason not to make it harder though... Archive your files but never think your files will be safe forever. It's always good to archive your files but when people want it, they will break it. Even AAA game protection could be broken by hackers.
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Protecting Files

#6 Post by Asceai »

The other thing I thought about, which is only a very weak 'security through obscurity' modification is to make a slight alteration to the Ren'Py code, putting a little bit of data at the start of the .rpa archives and ignoring it when reading. Then package and distribute using your modified Ren'Py. This will protect you from existing tools until someone notices your little trick.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Protecting Files

#7 Post by xela »

Kaen wrote:What do you mean xela? Feel free to share if you want.
Asceai explained in detail exactly what I've meant :)
Like what we're doing? Support us at:
Image

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Protecting Files

#8 Post by Asceai »

You can also obscure your scripts a little bit (actually, just the text in them) by creating a custom font which is whatever your regular font is, but with the codepoints shuffled. You could make the font contain a ton of duplicates of characters (unicode has codepoints to spare) and when you write a tool to obscure your scripts, just randomly pick from the duplicates. This kind of protection would be annoying to get around (because the information about the sequence is encoded in the font, rather than in an easily-reversed script packaged with the game) but it's only useful for protecting the text in your scripts, which is rarely the most important thing to people.

User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Re: Protecting Files

#9 Post by Kaen »

Thank you everyone for your suggestions.

While taking a look at Uncle Mugen's DSE I noticed that most of the files are encrypted (?) as a Thumbs.db file.

Does anyone know what exactly is this and how to do this?

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Protecting Files

#10 Post by Asceai »

Kaen wrote:Thank you everyone for your suggestions.

While taking a look at Uncle Mugen's DSE I noticed that most of the files are encrypted (?) as a Thumbs.db file.

Does anyone know what exactly is this and how to do this?
Nope, thumbs.db is just a file Windows automatically creates to store thumbnails of image files. renpy never uses it.

User avatar
Ran08
Miko-Class Veteran
Posts: 737
Joined: Tue Jun 12, 2012 1:17 am
Completed: https://ran.itch.io/
Projects: Fate's Cafe
Tumblr: otometwist
Skype: @otomeran
itch: ran
Location: Manila
Contact:

Re: Protecting Files

#11 Post by Ran08 »

I archive my files too, hahaha, especially the scripts. I tend to have weird ##comments## in there. Lol. But I think it doesn't matter much. After all, like what the others have said, if someone wants to open your files, they'll find ways to do it. :D Plus, I think there's a benefit to leaving your scripts open. ;)

Post Reply

Who is online

Users browsing this forum: Lacha