This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Reinified's profile picture

Need to protect files

Started by Reinified, 20 May 2017 - 04:00 PM
Reinified #1
Posted 20 May 2017 - 06:00 PM
So I am making a program that will attempt to detect if an unauthorised user has accessed the system.

Once I find that someone has accessed the system, I want them to not be able to access any of the files on the pc (run, edit, maybe even read.)

Is there a way?
KingofGamesYami #2
Posted 20 May 2017 - 06:53 PM
If the computer can be broken anyone can delete, rename, or create files by placing said computer in a disk drive. There is nothing you can do to prevent these actions.

You could encrypt the contents of your files. However, they will not be usable until you decrypt them.

Other people can also access the computer while you do. There is no way to prevent that from occuring, so refrain from decrypting any files when someone else is near.

TL;DR: Security is pointless in CC.
Reinified #3
Posted 20 May 2017 - 07:32 PM
Thanks for the answer. Can you hint me a good way to encrypt/decrypt the files?
KingofGamesYami #4
Posted 20 May 2017 - 10:21 PM
You could contact our resident encryption/security expert, Anavrins for an idea of the best algorithm to use.

The only encryption algorithm I know of is SquidDev's implementation of AES.
cntkillme #5
Posted 20 May 2017 - 10:31 PM
You could always edit bios.lua and have it require a password to boot from the disk and to change it can't you?
KingofGamesYami #6
Posted 20 May 2017 - 11:31 PM
That would apply to all computers, and require modification of the mod itself. Not really feasible.

It also does not prevent me from pickaxing your computer, placing it in a disk drive, and reading through your files at my leisure.
Edited on 20 May 2017 - 09:32 PM
cntkillme #7
Posted 20 May 2017 - 11:51 PM
Hmm, didn't realize you could insert a computer in a disk drive. Gotta rely on other mods to prevent people from breaking your stuff I guess.
Reinified #8
Posted 21 May 2017 - 05:47 AM
I think I'll go for the AES for lua by SquidDev. Thanks for the help.
Reinified #9
Posted 21 May 2017 - 06:34 AM
How would I encrypt each program? I've been experimenting, and here's what I have now:
http://pastebin.come/pXidabpb
It will simply return an "expected string, string" error on line 7.
KingofGamesYami #10
Posted 21 May 2017 - 01:52 PM
This page is no longer available. It has either expired, been removed by its creator, or removed by one of the Pastebin staff.
Anavrins #11
Posted 21 May 2017 - 08:11 PM
The best way to go about this is to modify fs.open in a way that it decrypts the contents on the fly, that way your file will never be in the clear on your disk.
To access them, you'd have a password lock, the password is used to derive a key to your files.
If somebody bypasses the lock, he will not be able to read its content, though nothing prevents him to modify or delete the files.

I've made this kind of program a while back, haven't touched it in a while and is not quite ready for a release, but it is possible to do.
Edited on 21 May 2017 - 06:11 PM