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

[Question] Make a program permanently un-editable?

Started by Zalerinian, 30 June 2012 - 04:30 PM
Zalerinian #1
Posted 30 June 2012 - 06:30 PM
Hello,

I'm making a program and i need it to be as secure as possible. If disk boot was not a factor, is there a way to make a file permanently un-editable? I managed to make it un-editable for a little, as in you try to edit ti and it throws an error, but then it will open to be edited if you input the edit command again. Is there any way to fix this to make it so it will still won't be editable after the first time?



EDIT: I fixed it myself, nevermind.
Edited on 30 June 2012 - 06:11 PM
Klausar #2
Posted 01 July 2012 - 04:26 PM
Can you tell us how you fixed it? Would be helpful for people having the same issue.
tfoote #3
Posted 02 July 2012 - 02:33 AM
Can you tell us how you fixed it? Would be helpful for people having the same issue.

Yes!!! Please do
Deathknight0897 #4
Posted 04 July 2012 - 11:11 AM
The best and easiest way to make a file un editable is to delete the edit program from the rom as simple as typing "delete edit" but as stated in post it is almost impossible to make it un editable anyways once u have removed edit you then want to block any external device's forcing a shutdown yeh that should do it
Cloudy #5
Posted 04 July 2012 - 12:54 PM
Except you can't delete files form the rom.
Pinkishu #6
Posted 04 July 2012 - 03:05 PM
You could compile the lua code and loadstring() it :3
Deathknight0897 #7
Posted 05 July 2012 - 05:31 AM
Except you can't delete files form the rom.
I am able to on my server in game maybe a setting
Lyqyd #8
Posted 05 July 2012 - 05:45 AM
There are no settings that would enable you to do such a thing.
Deathknight0897 #9
Posted 05 July 2012 - 05:56 AM
There are no settings that would enable you to do such a thing.
Thats really weird on my server i can just type Delete edit for example and it delete's it of that pc i promise im not doing anything special
Deathknight0897 #10
Posted 05 July 2012 - 06:37 AM
Ok so i was talking to my mate the server host and apperently he bugged computercraft on are server its now fixed however i just found a really easy way to stop edit from working type the following

edit edit

os.shutdown()

or if u dont want it to kill everything

os.reboot()

That will 100% lock the edit guaranteed even on server that havent been buggered by ur mate :P/>/>
:)/>/> send diamonds to me any time :D/>/>
Lyqyd #11
Posted 05 July 2012 - 06:39 AM
Nope, you're just making a file at /edit. You could still execute the normal edit by running /rom/programs/edit.
Deathknight0897 #12
Posted 05 July 2012 - 06:43 AM
1 sec going to test you has destroyed my plans i think
Deathknight0897 #13
Posted 05 July 2012 - 06:49 AM
Ok that's a small problem i found the way around that its simple but requires you to have access to the server or the rom folder go into it and cut edit from the rom now you need to place edit on every id of all the pcs and then just remove it from the pc's you down t want editable it requires alot of work but should work cant test as i don't own server and have no single players
Deathknight0897 #14
Posted 05 July 2012 - 09:27 AM
So did it work anyone going to tell me :P/>/>
Pinkishu #15
Posted 05 July 2012 - 10:27 AM
you can still run the lua console and re-write edit :P/>/>
Deathknight0897 #16
Posted 05 July 2012 - 11:22 AM
you can still run the lua console and re-write edit :P/>/>
Explain more and i will get around it most liklely

if its just another rom program then just do the same as before
Pinkishu #17
Posted 05 July 2012 - 12:04 PM
in console:
lua


then you use the fs api for writing files :P/>/>
KaoS #18
Posted 05 July 2012 - 12:07 PM
either way you can just open a new file, write whatever and then delete your existing file and then rename your new one to that name, has anyone tried making the server-side file read-only?
Pinkishu #19
Posted 05 July 2012 - 12:08 PM
Unless you edit ROM its impossible, if you edit ROM its easy
Deathknight0897 #20
Posted 05 July 2012 - 12:19 PM
that's why its called read only memory
Pinkishu #21
Posted 05 July 2012 - 12:23 PM
that's why its called read only memory

I meant editing the bios and such to make it possible :P/>/> not just sticking a file there
KaoS #22
Posted 05 July 2012 - 12:56 PM
and could you not use the shell.setAlias() command to assign the 'edit' or 'rom/programs/edit' alias to a random program

what I meant was opening your turtle and making the program you are protecting read only, then they cannot change it
Deathknight0897 #23
Posted 05 July 2012 - 12:56 PM
i believe so yeah that would work to
KaoS #24
Posted 05 July 2012 - 12:58 PM
i believe so yeah that would work to

lol, which one
Deathknight0897 #25
Posted 05 July 2012 - 12:59 PM
i believe so yeah that would work to
and could you not use the shell.setAlias() command to assign the 'edit' or 'rom/programs/edit' alias to a random program

what I meant was opening your turtle and making the program you are protecting read only, then they cannot change it
That one my freind
Pinkishu #26
Posted 05 July 2012 - 01:11 PM
i believe so yeah that would work to

lol, which one

Can't you still shell.run it? or cp it to a diff filename
KaoS #27
Posted 05 July 2012 - 01:27 PM
you can alias out lua if you like
Deathknight0897 #28
Posted 05 July 2012 - 01:27 PM
i still stick by the best method is to clear the rom and have all rom files run from its personal memory
KaoS #29
Posted 05 July 2012 - 01:35 PM
but then no-one else can use a PC as they need the rom files, is it not better that you just alias out what you think should be restricted rather than disabling all computers placed after your operation?
Deathknight0897 #30
Posted 05 July 2012 - 01:37 PM
thats why you copy all the rom files into the pc folder the programs still exist but you can delete the ones you no longer want for example on my server the rom folder is empty and we have set up a out of game script that fills a new folder ie id with the old rom files its basically best explained like this.


Everything still in the rom

Windows
its as safe as hell but you cant do much

put all the rom files in the pc and have the rom empty

Lynx
you can bugger it up something rotten but the possibilities

but then no-one else can use a PC as they need the rom files, is it not better that you just alias out what you think should be restricted rather than disabling all computers placed after your operation?
KaoS #31
Posted 05 July 2012 - 02:13 PM
Yes but if you place a new PC after you have done this then it gets a new folder which is empty, it will not have the files

sorry if I am misunderstanding what you are saying, kindly enlighten me
Deathknight0897 #32
Posted 05 July 2012 - 02:23 PM
no what you said there is correct the folder will be empty then you have 2 chooses you can either manually paste all the rom files so i keep a folder called backup rom that is on my desktop
you then can manually copy the whole backup rom to the new pc or you can set up an out of game script that will add those files to any new folder in that folder however i don't know how to do that as my mate is the server host and he made that script in c#
KaoS #33
Posted 05 July 2012 - 02:30 PM
you could create a file hosting server and rednet the files across if you like or as you say make a backup folder of the rom and then you can use an exterior script to keep checking for new folders in the computers directory and when one is detected it copies the files in and records that the folder has been taken care of (so if you delete a file it doesn't copy it in again)
KaoS #34
Posted 05 July 2012 - 02:33 PM
lol, we are thinking of so many outlandish ways of changing the system:)
MysticT #35
Posted 05 July 2012 - 03:11 PM
The only way to do this would be:
1) Go to rom and delete every program that can create files (ie, edit, lua, pastebin).
2) Do the same on every computer.
3) Now no one can create programs.

There's no way to stop people from creating new files. If there's just one computer that can edit files, it can make a floppy and copy them to every computer.
Pinkishu #36
Posted 05 July 2012 - 03:13 PM
Fun fact: the OP didn't even want to disable all editing :3
MysticT #37
Posted 05 July 2012 - 03:26 PM
Fun fact: the OP didn't even want to disable all editing :3
:P/>/>
You'r right, and it says it's already solved (not sure how, but solved), lol
Deathknight0897 #38
Posted 05 July 2012 - 05:32 PM
yeh but the two at the begging did and it was fun breaking all of dan 200 tools
Teraminer #39
Posted 11 July 2012 - 04:39 PM
This would not happen if we could make programs with names as "door lock" (now when you do that the program wil be "door" and not "door lock")
ahmut #40
Posted 11 February 2013 - 12:45 PM
anyone able to give me a step by step walk through on how to make it to where people cannot write programs onto a server?
Djerun #41
Posted 11 February 2013 - 01:17 PM
having a sightly edited shell as a startup program with certain command blacklisted would work by adding "edit <program path/program name>" and "edit startup" as well as "edit /startup", "lua" + direct path and direct path with leading "/" + "shell" + direct path and direct path with leading "/" on the blacklist and if your blacklist actually is a file ofc "edit <blacklistpath/blacklistfile>" with maybe an exception for this/the startup shell where you would need to enter a password to edit (but that would be saved in plain text on the computer unless you create an overly confusing routine to generate it at runtime but definetly dont use one of your normal passwords)

EDIT (after reading the 2nd page): add all other things that make it further possibe to get access to that program to the blacklist is probably only possible if you add edit and alias to the blacklist as well as copying removing and moving any files involved
PixelToast #42
Posted 11 February 2013 - 01:59 PM
i just open it in startup and make sure the file handle dosent get collected
Djerun #43
Posted 11 February 2013 - 02:04 PM
i just open it in startup and make sure the file handle dosent get collected
any specifications on how exactly?
PixelToast #44
Posted 11 February 2013 - 02:54 PM
fs.open("file_to_protect","r")
Grim Reaper #45
Posted 11 February 2013 - 03:01 PM
You could always just override the fs.open() global function to not return a handle to the file requested if its your file.
Just put this as your startup script:



local FILE_TO_PROTECT = "/myFile"
local old_fsOpen      = _G["fs"]["open"]

_G["fs"]["open"] = function (path, mode)
    if shell.resolveProgram (path) == shell.resolveProgram (FILE_TO_PROTECT) then
        return nil
    end

    return old_fsOpen (path, mode)
end