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

Computer Startup Lock

Started by ChaddJackson12, 01 October 2012 - 12:10 PM
ChaddJackson12 #1
Posted 01 October 2012 - 02:10 PM
Computer Lock
Current Version: 2.0

I have made a computer lock which locks your computer at startup with a password of your choice! This program is CTRL + T Safe, meaning that they cannot terminate this lock, without destroying the computer. (Unless the computer is labeled, of course.)

Key Interactions:
SpoilerKey interactions are only available at the main screen.
- Enter Key: Prompts User For Password
- Insert Key: Prompts User To Change Password
- Delete Key: Prompts User To Uninstall ComputerLock

How to install this program:
SpoilerMake sure HTTP is enabled, or this will not work! Check out how to enable HTTP below.

1. Go to a computer
2. On the computer, type: pastebin get 9zAZF5pB startup
3. Restart the computer.

How to enable HTTP:
Spoiler1. Go to the root directory of the game, .minecraft/.techniclauncher, ect…
2. Make sure that you are in the folder that contains the Saves, Bin, ect.
3. In that folder, open the Config folder.
4. Find the file that is for computercraft. Mod_Computercraft
5. Open it and change enableAPI_http=0 to enableAPI_http=1
6. Save the file, and you're done! You may need to reboot the game though!

Changelog:
V 2.0
Spoiler- Last release of the program.
- Added More Key Interactions At The Startup Menu (Not Visible Onscreen)
- Added Uninstaller
- Added Changeable Password Capabilities
- Cleaned Up Menu
V 1.0
Spoiler- First release of the program.
- Added User defined lock for protection, activated at startup.

CODE:
Spoiler


os.pullEvent = os.pullEventRaw
-- Local Variables --
local root = ".ComputerLock/Lock/"

-- Functions --
--[[ Password ]]--
function invalid()
term.clear()
term.setCursorPos(1,1)
print("Invalid Input!")
os.sleep(2)
os.reboot()
end

function uninstall()
print("nDo You Want To Uninstall ComputerLock? Yes / No")
write("n> ")
local input = read()
if input == "Yes" or input == "yes" then
write("nEnter Current Password: ")
local input = read("*")
pr = fs.open(root .. "password", "r")
Password = pr.readLine()
pr.close()
if input == Password then
fs.delete(".ComputerLock")
fs.delete("startup")
print("nComputerLock Uninstalled!")
os.reboot()
else
print("nIncorrect Password!")
os.sleep(2)
os.reboot()
end
elseif input == "No" or input == "no" then
os.reboot()
else
invalid()
end
end

function reSetNewPass()
print("nPasswords Do Not Match!")
os.sleep(2)
setNewPass()
end

function setNewPass()
write("nEnter New Password: ")
NewPass = read("*")
write("Confirm New Password: ")
ConfirmNewPass = read("*")
if NewPass == ConfirmNewPass then
fs.delete(root .. "password")
pw = fs.open(root .. "password", "w")
pw.writeLine(ConfirmNewPass)
pw.close()
print("nNew Password Set!")
os.sleep(2)
login()
else
reSetNewPass()
end
end

function changePass()
print("nDo You Want To Change The Password? Yes / No")
write("n> ")
local input = read()
if input == "Yes" or input == "yes" then
write("nEnter Current Password: ")
local input = read("*")
pr = fs.open(root .. "password", "r")
Password = pr.readLine()
pr.close()
if input == Password then
setNewPass()
else
print("nIncorrect Password!")
os.sleep(2)
os.reboot()
end
elseif input == "No" or input == "no" then
os.reboot()
else
invalid()
end
end

function reSetPass()
print("nPasswords Do Not Match!")
os.sleep(2)
setPass()
end

function setPass()
fs.makeDir(".ComputerLock")
fs.makeDir(".ComputerLock/Lock")
write("nPlease Enter Your Password: ")
local PassEnter = read("*")
write("Please Confirm Your Password: ")
local PassConfirm = read("*")
if PassEnter == PassConfirm then
pw = fs.open(root .. "password", "w")
pw.write(PassConfirm)
pw.close()
print("nPassword Has Been Set!")
os.sleep(2)
login()
else
reSetPass()
end
end

function prolong()
print("nOk")
os.sleep(1)
print("nExiting ComputerLock")
os.sleep(2)
term.clear()
term.setCursorPos(1,1)
print("CraftOS")
return
end

function correctPass()
print("nCorrect Password!")
os.sleep(2)
term.clear()
term.setCursorPos(1,1)
print("CraftOS")
return
end

function incorrectPass()
print("nIncorrect Password!")
os.sleep(1)
os.reboot()
end

function reLogin()
login()
end

function login()
term.clear()
term.setCursorPos(1,1)
print("ComputerLock 2.0")
print("nThis Computer Is Locked!")
print("Press [Enter] To Unlock!")
repeat
event, key = os.pullEvent("key")
os.sleep(0.1)
until key == 28 or key == 210 or key == 211
if key == 28 then
write("nEnter The Password: ")
local input = read("*")
pr = fs.open(root .. "password", "r")
Password = pr.readLine()
pr.close()
if input == Password then
correctPass()
else
incorrectPass()
end
elseif key == 210 then
changePass()
elseif key == 211 then
uninstall()
end
end

-- Main --
term.clear()
term.setCursorPos(1,1)
if fs.exists(root .. "password") then
login()
elseif not fs.exists(root .. "password") then
print("Your ComputerLock Password Has Not Been Set!")
os.sleep(1)
print("nWould You Like To Set It Now? Yes / No")
write("n> ")
local input = read()
if input == "Yes" or input == "yes" then
setPass()
elseif input == "No" or input == "no" then
prolong()
else
invalid()
end
end
Please do not reupload, distribute, or change this code. If you have any questions the you may contact me. I would be more than happy to answer them.
jag #2
Posted 01 October 2012 - 02:46 PM
It's cool how you hid the password, but if you do
edit .ComputerLock/Lock/pw
you can easily change the password. (ofc, you don't even see the ComputerLock folder, so no-one will find the file)
jag #3
Posted 01 October 2012 - 02:53 PM
And plus, I see how your code is done with the alignment on your pastebin.
You know, when the code "jumps out". Like this
if someStatment() then
  print("Useless code!")
  ↖ the code starts here
↖ not here
end
But you don't got that alignment in your code here.
jag #4
Posted 01 October 2012 - 03:02 PM
At some point you are doing
Password = pr.readLine(Password)
but you know, readLine dosen't need any parameters..
ChaddJackson12 #5
Posted 01 October 2012 - 10:36 PM
And plus, I see how your code is done with the alignment on your pastebin.
You know, when the code "jumps out". Like this
if someStatment() then
  print("Useless code!")
  ↖ the code starts here
↖ not here
end
But you don't got that alignment in your code here.
Ok, well I will review that, but I don't usually put an indent after print(), but after something that needs an end.
ChaddJackson12 #6
Posted 01 October 2012 - 10:38 PM
It's cool how you hid the password, but if you do
edit .ComputerLock/Lock/pw
you can easily change the password. (ofc, you don't even see the ComputerLock folder, so no-one will find the file)
Yes, but I don't know how to make an encryption thing or something like binary for the numbers. If you know how, could you please tell me? That would be something that I am very interested in knowing.

Also, on a multiplayer server (which this is probably going to be used on the most) Don't you have to have access to the computer console BEFORE editing? When entering the password, you can't use CTRL + T to edit the password file. Anyway, I will still fix this issue when I find a way to encrypt something.
ChaddJackson12 #7
Posted 01 October 2012 - 10:42 PM
At some point you are doing
Password = pr.readLine(Password)
but you know, readLine dosen't need any parameters..

I know very little about readLine(). But I use the readLine(Password) for reference to that 'line'

pr.readLine(Password)
pr.close()

-- Right here
if input == Password then

But I guess I could do this.


Password = pr.readLine()

Anyway, I will try that out and see how it goes.
jag #8
Posted 01 October 2012 - 11:14 PM
I found a way of encrypting!
Here, on pastebin: Hz5zR22t
Raw code:
Spoiler
key = 5
function encrypt(data) 
 i = 1
 enc = ""
 repeat 
 enc = enc .. string.char(data:byte(i) + key)
 i = i+1
 until data:byte(i) == nil 
 return enc
end
function decrypt(data)
 i = 1
 dec = ""
 repeat
 dec = dec .. string.char(data:byte(i) - key)
 i = i + 1
 until data:byte(i) == nil
 return dec
end
ChaddJackson12 #9
Posted 02 October 2012 - 12:25 AM
I found a way of encrypting!
Here, on pastebin: Hz5zR22t
Raw code:
Spoiler
key = 5
function encrypt(data)
i = 1
enc = ""
repeat
enc = enc .. string.char(data:byte(i) + key)
i = i+1
until data:byte(i) == nil
return enc
end
function decrypt(data)
i = 1
dec = ""
repeat
dec = dec .. string.char(data:byte(i) - key)
i = i + 1
until data:byte(i) == nil
return dec
end

Oh, thank you very much! :)/>/> I guess I could make an update for this and include encryption, and the possibility to change the password.
ChaddJackson12 #10
Posted 03 October 2012 - 01:31 AM
I found a way of encrypting!
Here, on pastebin: Hz5zR22t
Raw code:
Spoiler
key = 5
function encrypt(data)
i = 1
enc = ""
repeat
enc = enc .. string.char(data:byte(i) + key)
i = i+1
until data:byte(i) == nil
return enc
end
function decrypt(data)
i = 1
dec = ""
repeat
dec = dec .. string.char(data:byte(i) - key)
i = i + 1
until data:byte(i) == nil
return dec
end
I have attempted to encrypt the file, which works. However, the decryption does not work properly, for some reason that I cannot seem to find out, so I will not be using it at this time. :(/>/>
jag #11
Posted 03 October 2012 - 08:30 AM
I found a way of encrypting!
Here, on pastebin: Hz5zR22t
Raw code:
Spoiler
key = 5
function encrypt(data)
i = 1
enc = ""
repeat
enc = enc .. string.char(data:byte(i) + key)
i = i+1
until data:byte(i) == nil
return enc
end
function decrypt(data)
i = 1
dec = ""
repeat
dec = dec .. string.char(data:byte(i) - key)
i = i + 1
until data:byte(i) == nil
return dec
end
I have attempted to encrypt the file, which works. However, the decryption does not work properly, for some reason that I cannot seem to find out, so I will not be using it at this time. :(/>/>
Well it worked for me!
ChaddJackson12 #12
Posted 04 October 2012 - 02:51 AM
I found a way of encrypting!
Here, on pastebin: Hz5zR22t
Raw code:
Spoiler
key = 5
function encrypt(data)
i = 1
enc = ""
repeat
enc = enc .. string.char(data:byte(i) + key)
i = i+1
until data:byte(i) == nil
return enc
end
function decrypt(data)
i = 1
dec = ""
repeat
dec = dec .. string.char(data:byte(i) - key)
i = i + 1
until data:byte(i) == nil
return dec
end
I have attempted to encrypt the file, which works. However, the decryption does not work properly, for some reason that I cannot seem to find out, so I will not be using it at this time. :(/>/>
Well it worked for me!
Yeah I could get it to work, for printing/writing. What I couldn't get to work properly was the password decryption from the file, it would pretty much just scramble it up even worse, rather than returning it to normal. :/
Orwell #13
Posted 04 October 2012 - 03:03 AM
I found a way of encrypting!
Here, on pastebin: Hz5zR22t
Raw code:
Spoiler
key = 5
function encrypt(data)
i = 1
enc = ""
repeat
enc = enc .. string.char(data:byte(i) + key)
i = i+1
until data:byte(i) == nil
return enc
end
function decrypt(data)
i = 1
dec = ""
repeat
dec = dec .. string.char(data:byte(i) - key)
i = i + 1
until data:byte(i) == nil
return dec
end
I have attempted to encrypt the file, which works. However, the decryption does not work properly, for some reason that I cannot seem to find out, so I will not be using it at this time. :(/>/>
Well it worked for me!
Yeah I could get it to work, for printing/writing. What I couldn't get to work properly was the password decryption from the file, it would pretty much just scramble it up even worse, rather than returning it to normal. :/

Did you change the key to 130 or higher? It's not a really safe algorithm anyway. And as a char has the size of one byte, you run into trouble when the sum of the char and the key is higher than 255.
jag #14
Posted 04 October 2012 - 05:43 AM
Well I just searched on the web and that was the first one I found, it may not work in all cases but it's better then nothing!
dimitriye98 #15
Posted 04 October 2012 - 06:42 AM
Instead of encryption use a hash. Just compare a stored hash to newly calculated hash.
jag #16
Posted 04 October 2012 - 06:45 AM
Instead of encryption use a hash. Just compare a stored hash to newly calculated hash.
Wait, wut?
ChaddJackson12 #17
Posted 05 October 2012 - 12:02 AM
Instead of encryption use a hash. Just compare a stored hash to newly calculated hash.
Instead of encryption, I would rather use something where I made a table that makes letters = numbers, and stuff like that. But I don't know how to pull that off. Also, the numbers would be more than 1, more like 3 numbers per letter, so that it is more complex…
jag #18
Posted 05 October 2012 - 07:20 AM
Instead of encryption use a hash. Just compare a stored hash to newly calculated hash.
Instead of encryption, I would rather use something where I made a table that makes letters = numbers, and stuff like that. But I don't know how to pull that off. Also, the numbers would be more than 1, more like 3 numbers per letter, so that it is more complex…
Well if you encode it like that, you can then later take 3 numbers at a time and making it into a letter, then putting in the letter in a new variable.
1lann #19
Posted 05 October 2012 - 06:05 PM
Go use tomas1996's textutils api or something. He has multiple types of hash and they take advantage of cc's bit API. SHA1 would be the most secure.
ChaddJackson12 #20
Posted 06 October 2012 - 04:11 PM
Go use tomas1996's textutils api or something. He has multiple types of hash and they take advantage of cc's bit API. SHA1 would be the most secure.
Alright, sounds cool, I will check it out soon.
MemoryLeak21 #21
Posted 08 December 2012 - 02:10 PM
It's completely impossible in ComputerCraft to lock anything at all – people can just use a disk drive to fire up a startup that reads your own startup, figures out the encryption, and decrypts that password.
Cranium #22
Posted 08 December 2012 - 02:43 PM
It's completely impossible in ComputerCraft to lock anything at all – people can just use a disk drive to fire up a startup that reads your own startup, figures out the encryption, and decrypts that password.
Not if you use encryption.decryption via http using a php script.
bjornir90 #23
Posted 08 December 2012 - 10:22 PM
It's completely impossible in ComputerCraft to lock anything at all – people can just use a disk drive to fire up a startup that reads your own startup, figures out the encryption, and decrypts that password.
Or he can just boot with a disk and the password lock is overpassed
Goof #24
Posted 09 December 2012 - 03:06 AM
Cranium. Okay. I talked with some moderators, and they told me that what you say about php encryption.decryption is not avaible..
but if you Are that much sure that it works, then please tell me how to.

thanks
ChaddJackson12 #25
Posted 09 December 2012 - 06:38 AM
Cranium. Okay. I talked with some moderators, and they told me that what you say about php encryption.decryption is not avaible..
but if you Are that much sure that it works, then please tell me how to.

thanks
How about just having an online pastebin/dropbox file, containing the encryption? Have it download the encryption, but never actually have the encryption in the file. That way it would make it so something couldn't figure out the encrytion (As easily).

Also, it is impossible to lock anything in computercraft if you know what you're doing, but I made this because I was bored, not because it is 100% secure. Nothing on computercraft is.
Goof #26
Posted 09 December 2012 - 11:41 AM
Yeah but, you still cant preventbdisk booting, without editing the shell / cc bios. Thats what the cc forum, admins told me. :-)

-mikk809h
MemoryLeak21 #27
Posted 09 December 2012 - 02:29 PM
You could probably make some way so that the computer can't be turned off, and only goes into a "sleep" state, but I wouldn't try doing that unless you have a good knowledge of the stack and how not to crash your program.
ChaddJackson12 #28
Posted 09 December 2012 - 07:16 PM
You could probably make some way so that the computer can't be turned off, and only goes into a "sleep" state, but I wouldn't try doing that unless you have a good knowledge of the stack and how not to crash your program.
You can't because people can hold Ctrl + S
MemoryLeak21 #29
Posted 09 December 2012 - 07:31 PM
You could probably make some way so that the computer can't be turned off, and only goes into a "sleep" state, but I wouldn't try doing that unless you have a good knowledge of the stack and how not to crash your program.
You can't because people can hold Ctrl + S

You can disable that with:


os.pullEvent = os.pullEventRaw
Cranium #30
Posted 09 December 2012 - 07:42 PM
You can disable that with:


os.pullEvent = os.pullEventRaw
Ctrl + S CANNOT be prevented. EVER. It is hardcoded into Java, and will ALWAYS work.
rhyleymaster #31
Posted 09 December 2012 - 08:12 PM
You can disable that with:


os.pullEvent = os.pullEventRaw
Ctrl + S CANNOT be prevented. EVER. It is hardcoded into Java, and will ALWAYS work.

Lolwut? Why not set a Keybind over CTRL + S to make it run a program on shell? Of coarse you'd need to modify the roms but theres no real risk (beside's complete corruption…)
Cranium #32
Posted 09 December 2012 - 09:38 PM
Even if you modify the BIOS, CTRL + S would still shutdown the computer. Again, no action you take on the computer would prevent the interruption of CTRL + S or CTRL + R. Both are hardcoded into Java, and cannot be bypassed.
ChaddJackson12 #33
Posted 10 December 2012 - 04:35 AM
You could probably make some way so that the computer can't be turned off, and only goes into a "sleep" state, but I wouldn't try doing that unless you have a good knowledge of the stack and how not to crash your program.
You can't because people can hold Ctrl + S

You can disable that with:


os.pullEvent = os.pullEventRaw
Let's not post 50 replies saying that there is a way to prevent Ctrl + S… It's impossible, same with Ctrl + R. The only thing that can be disabled is Ctrl + T. That just exits the program.
ChaddJackson12 #34
Posted 10 December 2012 - 04:37 AM
You can disable that with:


os.pullEvent = os.pullEventRaw
Ctrl + S CANNOT be prevented. EVER. It is hardcoded into Java, and will ALWAYS work.

Lolwut? Why not set a Keybind over CTRL + S to make it run a program on shell? Of coarse you'd need to modify the roms but theres no real risk (beside's complete corruption…)
I've tried that, and they still only hold it down for 1 second, and it turns off the computer no matter what.
MemoryLeak21 #35
Posted 10 December 2012 - 06:33 AM
Really? I was not aware.

One thing, though, if you are on a public server and you hide the disk drive, no one will be able to boot it with a disk. :P/>
ChaddJackson12 #36
Posted 10 December 2012 - 06:49 PM
Really? I was not aware.

One thing, though, if you are on a public server and you hide the disk drive, no one will be able to boot it with a disk. :P/>
Perhaps, but they just need one of their own to attach to the computer.
bjornir90 #37
Posted 10 December 2012 - 06:52 PM
-snip-
Perhaps, but they just need one of their own to attach to the computer.
No because if you put it on the top, it will be loaded first in the top, and if there is not startup on it it will check on right, on left etc etc …
MemoryLeak21 #38
Posted 11 December 2012 - 04:20 AM
-snip-
Perhaps, but they just need one of their own to attach to the computer.

If they can place a disk drive next to your computer I'm sure they would have other priorities…