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

[Lua] Highly Secure Door lock

Started by Deathknight0897, 05 July 2012 - 04:11 AM
Deathknight0897 #1
Posted 05 July 2012 - 06:11 AM
This is a 100% secure door lock that servers the simple function of unlocking a door this is my first total notepad++ wrote code so tell me what you think also please feel free to report anyways you find to bypass it in the console.

Warning once u reboot the only way you will be able to edit the code is if u have access to the computers save file on the server

Code
Those who know what there doing

Put it all in your start up

os.pullEvent = os.pullEventRaw
local standby = 10
local side = "top"
local password = "Example"
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Well done")
rs.setOutput(side,true)
sleep(Standby)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Your a failure just like trolls in this topic")
sleep(2)
os.reboot()
end

Guide
Just in case your a little unsure

this is one of the most secure pass worded doors you can create have a go and please reply in the comment section if you run into any problems with this guide.

Step 1
If your not sure how to place the console i would suggest you take a look at my other guide http://www.computerc...__fromsearch__1

"edit startup" now enter this heap of code it is commented to enjoy

os.pullEvent = os.pullEventRaw
local opentime = 10 -- Change the 10 how long the door or what ever will stay open
local side = "left" -- Change to where the door is left, right, front, back, bottom, top
local password = "Password" -- Change Password to what you want your password to be.
term.clear()
term.setCursorPos(1,1)
write("Password: ")  -- change this if u wish to have a cutom prompt
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Well done you made a lock") -- Change this if you wish to have a custom congratulations
rs.setOutput(side,true)
sleep(opentime)
rs.setOutput(side,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!") -- Change this if you wish to have a custom fail message
sleep(2)
os.reboot()
end

that is it your done its that simple if you want to understand more of what you just did i would suggest checking the tutorial page on the forums for information about if statements and local variables

One last little note from my testing i kept forgetting it was case sensitive make sure you remember to capitalize correctly your password or you may be the one locked out.

I am aware this is identical to the one on the wiki it is most likely the tutorials i looked at were using it as reference it is my own work as i typed it and modified to my liking however if you think there is no need having this tutorial let me know and ill remove it got bigger and better programs on the horizon anyways
Edited on 05 July 2012 - 04:06 PM
MysticT #2
Posted 05 July 2012 - 04:07 PM
100% secure… until someone places a disk drive and inserts a floppy with a startup file, reboots your computer and has access to it.
Also, this is the code from the wiki tutorial, so posting it like your program is really stupid.
Deathknight0897 #3
Posted 05 July 2012 - 05:37 PM
Its not :c i made it on my lonesome it probably looks similar as there is only so many ways you can skin a cat XD
don't use the wiki other than for the api's only have used the forums

and yeh i know about the disc drive that is a problem
MysticT #4
Posted 05 July 2012 - 05:42 PM
So it's just a coincidence you used all the same variable names? I don't think so. You either copied it from the wiki, or from someone else that posted it here (and there's a lot of posts with that same code).
Deathknight0897 #5
Posted 05 July 2012 - 05:53 PM
Fine if it makes you happy ill change the variables would that make you happy and actually no i looked at some proper lua tutorials to learn this then converted it into a working version for computer craft man some people
MysticT #6
Posted 05 July 2012 - 05:57 PM
The problem is not the variable names, it's that it is the exact same code from the wiki tutorial:

local side = "left" -- Change left to whatever side your door / redstone is on, E.G: left, right, front, back, bottom, top. Be sure to leave the "s around it, though
local password = "bacon" -- Change bacon to what you want your password to be. Be sure to leave the "s around it, though
local opentime = 5 -- Change 5 to how long (in seconds) you want the redstone current to be on. Don't put "s around it, though
term.clear() -- Clears the screen
term.setCursorPos(1,1) -- Fixes the cursor position
write("Password: ") -- Prints 'Password: ' to the screen
local input = read("*") -- Makes the variable 'input' have the contents of what the user types in, the "*" part sensors out the password
if input == password then -- Checks if the user inputted the correct password
term.clear() -- Already explained up top
term.setCursorPos(1,1)
print("Password correct!") -- Prints 'Password correct!' to the screen
rs.setOutput(side,true) -- Output a redstone current to the side you specified
sleep(opentime) -- Wait the amount of seconds you specifed, then..
rs.setOutput(side,false) -- Stop outputting a redstone current
os.reboot() -- Reboot the computer, reopening the lock
else -- Checks if the user didn't input the correct password
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!") -- Prints 'Password incorrect!' to the screen
sleep(2) -- Waits 2 seconds
os.reboot() -- Reboot the computer, reopening the lock
end
It's ok if you want to post a tutorial on how to set it up (although it's already explained in the wiki tutorial), but don't say it's your code.
Deathknight0897 #7
Posted 05 July 2012 - 06:00 PM
oh dear god i will admit its similar but honestly i didn't use that as my source of information i wont remove the topic as it still serves a function unlike this discussion i coded it myself yes the varibles are named the same yes its in the same order it wouldn't make much sense to ask for a password after ive opened the door now would it

I have made many other programs now why don't you go find a couple of programs like them im sure u will as that is the nature of the beast more than one person will have the same idea.

and may even look at a same tutorial and maybe even use the same variable magic isn't it the world wide web
atticnatalex #8
Posted 15 July 2012 - 12:24 AM
nope. sleep uses os.pullEvent() , which means when it sleeps it can bypassed with CTRL + T

so:
Write this at your script's start:
local oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw

and this at your scripts end:
os.pullEvent = oldPullEvent



now it's 100% unhackable. tell me if I'm wrong.
Exerro #9
Posted 15 July 2012 - 11:34 AM
i made a virus that could pwn that doorlock…to make it harder to hack put

oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
while true do
if fs.exists("disk") then
k = fs.open("disk/startup", "w")
k.writeLine("")
k.close()
disk.eject("back")
disk.eject("bottom")
disk.eject("top")
disk.eject("front")
disk.eject("left")
disk.eject("right")
<code>
end
end
os.pullEvent = oldPullEvent

this should erase the disk startup and eject the disk when it is put in…
Deathknight0897 #10
Posted 15 July 2012 - 04:11 PM
Nice Awsumben i will try that out wicked to see some addons to the code
i made a virus that could pwn that doorlock…to make it harder to hack put

oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
while true do
if fs.exists("disk") then
k = fs.open("disk/startup", "w")
k.writeLine("")
k.close()
disk.eject("back")
disk.eject("bottom")
disk.eject("top")
disk.eject("front")
disk.eject("left")
disk.eject("right")
<code>
end
end
os.pullEvent = oldPullEvent

this should erase the disk startup and eject the disk when it is put in…
luingar #11
Posted 15 July 2012 - 10:42 PM
Works fine, til you try to get it to work when no disk exists. then it times out with "too long without yeilding"… any idea how to fix it?
Edited on 15 July 2012 - 09:54 PM
Lasere123456 #12
Posted 27 July 2012 - 12:06 AM
her is a little upgrade, that lets you access the consol


os.pullEvent = os.pullEventRaw
local standby = 10
local side = "top"
local password = "Example"
local consolPassword = "ExampleAdmin"
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local input = read("*")
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Well done")
rs.setOutput(side,true)
sleep(Standby)
rs.setOutput(side,false)
os.reboot()
elseif input == ConsolPassword
term.clear()
term.setCursorPos(1,1)
print("Consol access granted")
else
term.clear()
term.setCursorPos(1,1)
print("Your a failure just like trolls in this topic")
sleep(2)
os.reboot()
end
Laserman34170 #13
Posted 27 July 2012 - 12:29 AM
My system really is secure. It never reboots, so the disk startup file won't work. Also, it uses data from a server, and if you masquerade as the terminal it still won't work as the terminal id and password are hard coded.
Laserman34170 #14
Posted 30 July 2012 - 10:44 PM
i made a virus that could pwn that doorlock…to make it harder to hack put

oldPullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
while true do
if fs.exists("disk") then
k = fs.open("disk/startup", "w")
k.writeLine("")
k.close()
disk.eject("back")
disk.eject("bottom")
disk.eject("top")
disk.eject("front")
disk.eject("left")
disk.eject("right")
<code>
end
end
os.pullEvent = oldPullEvent

this should erase the disk startup and eject the disk when it is put in…

You know, that doesn't work either, because the rom is programmed to always boot from the disk/startup if any, and then, if there is no disk/startup, boot the normal startup file on the computer.
KingMachine #15
Posted 01 August 2012 - 04:27 AM
100% secure until I use a quick paste program to exit out of your startup.
RoD #16
Posted 07 July 2013 - 02:09 PM
i created a even more secure login program. It has a rednet connection with another computer witch has the password saved. It also has the os.pullEvent = os.pullEventRaw. So even someone can use a floppy disk to enter the computer and even that they edit the code the password dont show up. Of course, like other programs this one has a weak point and its not 100% impossible to bypass.
Here is the code for the computer that has the password(place it in a safe room):

shell.run("clear")
rednet.open("right")
pass = "password"--change here password
while true do
rednet.send(3, pass, true)--3 is the computer id so you need to change it for the actual id
sleep(0.1)
end
Heres is the code for the computer that users will insert the password(Please dont use this code in a computer that you have important codes and projects witout deleting the first line of the code or installing the program above in other computer(this code is not intended to be malicious)):

os.pullEvent = os.pullEventRaw
shell.run("clear")
rednet.open("right")
write("Password:")
passinput = read()
local senderId, pass = rednet.receive()
if passinput == pass then
print("Correct!")
sleep(1)
shell.run("clear")
else
print("Wrong!")
sleep(1)
shell.run("reboot")
end
So the computer that asks for the password will receive the password from the other computer and see if it is the same. If it is it will open terminal(and then it cant make more things…This is just an example).
Simple and more secure.. Yet is not the most safe program! people can make a program that receives the password from the computer that has the password and print it in the computer that asks for the password. :D/>
Grim Reaper #17
Posted 07 July 2013 - 02:19 PM
Just because you instruct the computer to eject a disk while it's on doesn't prevent the disk startup override hack. Ctrl + S will shutdown a computer so that you can insert a disk into the drive adjacent to the computer so you may restart the machine and have access to it. The only sure way to prevent that hack is to edit the bios or prevent disk drives from being placed next to your computer.
Dave-ee Jones #18
Posted 07 July 2013 - 07:55 PM
I hacked that SOOOO easily :P/>

P.S that was the first LUA code I ever learnt as well so I know it off by heart.
reububble #19
Posted 10 July 2013 - 06:25 AM
A'right this is all mine, written just then and now in this reply box. Tested once. Is not prone to disk, in fact will duplicate across stray disks. Cannot be turned off by any means including turtles and computers next to the computer. I suggest you set path to 'startup' so that Ctrl+R will be useless.



os.pullEvent = os.pullEventRaw
path = "startup" -- insert path name here
side = "top" -- insert redstone output side here
password = "password" -- insert password here
function primary()
while true do
  term.clear() term.setCursorPos(1,1)
  term.write("Enter Password")
  term.setCursorPos(1,2)
  if password == read('*') then
   rs.setOutput(side,true)
   sleep(2) --dw about it folks
   rs.setOutput(side,false)
  end
end
end
function secondary()
while true do
  ev,p1,p2,p3 = os.pullEvent()
  if ev=="key" then
   break
  elseif ev=="disk" then
   if fs.exists("disk/startup") then
	fs.delete("disk/startup")
   end
   h=fs.open("disk/startup",'w') i=fs.open(path,'r')
   repeat
	X=h.writeLine(i.readLine)
   until X==nil
   h.close() i.close()
   peripheral.call(p1,"ejectDisk")
  elseif ev=="peripheral" then
   pType=peripheral.getType(p1)
   if pType == "computer" or pType == "turtle" then
	parallel.waitForAll(secondary,function()
	while true do
	 os.queueEvent("blah") os.pullEvent("blah") --yielding
	 if peripheral.isPresent(p1) then
	  peripheral.call(p1,"shutdown")
	 else
	  break
	 end
	end end)
   end
  end
end
end
while true do
parallel.waitForAny(primary,secondary)
end
Xenthera #20
Posted 10 July 2013 - 04:06 PM
A'right this is all mine, written just then and now in this reply box. Tested once. Is not prone to disk, in fact will duplicate across stray disks. Cannot be turned off by any means including turtles and computers next to the computer. I suggest you set path to 'startup' so that Ctrl+R will be useless.

Not sure what you mean by "Not prone to disk" but this is just as easily 'hackable' as any other security program on here.
Without editing certain files outside of game, NOTHING is secure on computercraft.
TheGamerOfAction #21
Posted 11 July 2013 - 11:53 AM
The easy way to 'hack' the door is to just mine it down :lol:/>
Other than that, I'm not sure if you can hack it.
electrodude512 #22
Posted 11 July 2013 - 12:39 PM
i created a even more secure login program. It has a rednet connection with another computer witch has the password saved. It also has the os.pullEvent = os.pullEventRaw. So even someone can use a floppy disk to enter the computer and even that they edit the code the password dont show up. Of course, like other programs this one has a weak point and its not 100% impossible to bypass.

So the computer that asks for the password will receive the password from the other computer and see if it is the same. If it is it will open terminal(and then it cant make more things…This is just an example).
Simple and more secure.. Yet is not the most safe program! people can make a program that receives the password from the computer that has the password and print it in the computer that asks for the password. :D/>

Rednet messages can be intercepted by listening to the right channels. This could be made secure if you added some kind of encryption and a challenge-response sequence from the password server.
RoD #23
Posted 12 July 2013 - 05:58 AM
i created a even more secure login program. It has a rednet connection with another computer witch has the password saved. It also has the os.pullEvent = os.pullEventRaw. So even someone can use a floppy disk to enter the computer and even that they edit the code the password dont show up. Of course, like other programs this one has a weak point and its not 100% impossible to bypass.

So the computer that asks for the password will receive the password from the other computer and see if it is the same. If it is it will open terminal(and then it cant make more things…This is just an example).
Simple and more secure.. Yet is not the most safe program! people can make a program that receives the password from the computer that has the password and print it in the computer that asks for the password. :D/>

Rednet messages can be intercepted by listening to the right channels. This could be made secure if you added some kind of encryption and a challenge-response sequence from the password server.
Yup i know thats one of the projects i am working on…A encryption program i am getting a little confuse but i think i can menage it :D/> thnks for the advice
reububble #24
Posted 15 July 2013 - 09:21 AM
Not sure what you mean by "Not prone to disk" but this is just as easily 'hackable' as any other security program on here.
Without editing certain files outside of game, NOTHING is secure on computercraft.

I challenge you to break into the program while it's running, and saved in startup. You may use all keys, clicks, add peripherals and blocks around it, but you may NOT destroy the computer or search through the computercraft directory. Imagine the block is protected and you're on a server, the only way in is to either hack, or know the password.

By 'Not prone to disk' I mean that no matter what you do you will not be able to get the computer to restart with a disk/startup file. Please understand
rhyleymaster #25
Posted 15 July 2013 - 02:43 PM
The only way to make it 'Not prone to disk' is to edit the roms, which you cant do on a server unless you edit the resource pack itself.
reububble #26
Posted 15 July 2013 - 05:21 PM
The only way to make it 'Not prone to disk' is to edit the roms, which you cant do on a server unless you edit the resource pack itself.
No, no that is not the only way. Remember how computers can check if there is a disk near them and eject it instantly? Remember how you can ensure the computer is not turned off by the user (most people can do this part), and did you know that you can also stop any computer from turning your computer off also?
If you can't turn it off, can't insert a disk while it's on, and you're not allowed to break the computer/door, then how are you meant to get in without a password?
MysticT #27
Posted 15 July 2013 - 05:44 PM
The only way to make it 'Not prone to disk' is to edit the roms, which you cant do on a server unless you edit the resource pack itself.
No, no that is not the only way. Remember how computers can check if there is a disk near them and eject it instantly? Remember how you can ensure the computer is not turned off by the user (most people can do this part), and did you know that you can also stop any computer from turning your computer off also?
If you can't turn it off, can't insert a disk while it's on, and you're not allowed to break the computer/door, then how are you meant to get in without a password?
1) Press Ctrl+S to shut down the computer.
2) Place disk drive next to the computer.
3) Insert disk with blank startup file.
4) Click the computer to turn it on.
5) ????
6) PROFIT!

Also, why was this post revived? O.o
ElvishJerricco #28
Posted 15 July 2013 - 05:55 PM
The only way to make it 'Not prone to disk' is to edit the roms, which you cant do on a server unless you edit the resource pack itself.
No, no that is not the only way. Remember how computers can check if there is a disk near them and eject it instantly? Remember how you can ensure the computer is not turned off by the user (most people can do this part), and did you know that you can also stop any computer from turning your computer off also?
If you can't turn it off, can't insert a disk while it's on, and you're not allowed to break the computer/door, then how are you meant to get in without a password?

Yea MysticT's right. You can't stop ctrl+S from shutting a computer down, and other computers using the peripheral functions can't be stopped. If they can get a disk in the disk drive, you can't stop them getting in without editing the rom.
Xenthera #29
Posted 15 July 2013 - 08:23 PM
Not sure what you mean by "Not prone to disk" but this is just as easily 'hackable' as any other security program on here.
Without editing certain files outside of game, NOTHING is secure on computercraft.

I challenge you to break into the program while it's running, and saved in startup. You may use all keys, clicks, add peripherals and blocks around it, but you may NOT destroy the computer or search through the computercraft directory. Imagine the block is protected and you're on a server, the only way in is to either hack, or know the password.

By 'Not prone to disk' I mean that no matter what you do you will not be able to get the computer to restart with a disk/startup file. Please understand

It's quite ironic, because I did try to break in. Which, like I said, is really easy. You can't stop the computer from being shutdown, which is why it's so vulnerable.
reububble #30
Posted 16 July 2013 - 04:03 AM
Ctrl+S. I never even use Ctrl+S, no wonder. How about attach a computer to your computer which is told to continually turnOn the other computer until it knows you're not pressing Ctrl+S?


side="right" -- if the main computer is on the right
while true do
os.pullEvent("redstone")
if rs.getInput(side) then
  parallel.waitForAny(
   function()
	while true do
	 peripheral.call(side,turnOn)
         os.queueEvent('blah') os.pullEvent('blah') -- to yield
	end
   end,
   function()
	while true do
	 os.pullEvent("redstone")
	 if rs.getInput(side) then
	  break
	 end
	end
   end)
  end
end
end

Now all you need to do is to add into the previous code


if ev=="key" then
if p1=29 then
  rs.setOutput(side,true) sleep(0.05)
  rs.setOutput(side,false) -- remember that 'side' needs to be the side the other computer is on
else
  rs.setOutput(side,true) sleep(0.05)
  rs.setOutput(side,false)
end
end

this is fun!
MysticT #31
Posted 16 July 2013 - 10:43 AM
Ctrl+S. I never even use Ctrl+S, no wonder. How about attach a computer to your computer which is told to continually turnOn the other computer until it knows you're not pressing Ctrl+S?


side="right" -- if the main computer is on the right
while true do
os.pullEvent("redstone")
if rs.getInput(side) then
  parallel.waitForAny(
   function()
	while true do
	 peripheral.call(side,turnOn)
		 os.queueEvent('blah') os.pullEvent('blah') -- to yield
	end
   end,
   function()
	while true do
	 os.pullEvent("redstone")
	 if rs.getInput(side) then
	  break
	 end
	end
   end)
  end
end
end

Now all you need to do is to add into the previous code


if ev=="key" then
if p1=29 then
  rs.setOutput(side,true) sleep(0.05)
  rs.setOutput(side,false) -- remember that 'side' needs to be the side the other computer is on
else
  rs.setOutput(side,true) sleep(0.05)
  rs.setOutput(side,false)
end
end

this is fun!
Then just turn off the other computer first :P/>
reububble #32
Posted 16 July 2013 - 04:07 PM
Then just have the other computer also running the 'secondary' function from the first computer? :P/>
jesusthekiller #33
Posted 19 July 2013 - 06:30 AM
Holly smokes, next door lock…