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

Client/Server Password System

Started by DaRc, 10 January 2013 - 08:55 PM
DaRc #1
Posted 10 January 2013 - 09:55 PM
Morning everyone! I am still very new to ComputerCraft but am diving into it's depths pretty quick, trying to learn about as many of the API's as I can. I have watched hundreds of tutorials related to password coded door locks using CC 1.3 and CC 1.4. The basic password locks are kind of nice, but every once in a while I get a bit nervous about the security of my doors. Yesterday I build a completely automated Nuclear Reactor Facility (took me two weeks to plan it out and make it work right) xD, I placed a double Reinforced Stone Door with a computer coded lock. The lock is a multi variable lock that requires both a Username AND Password to match before the door will unlock. As previously noted… I'm kind of nervous about my doors, this facility required 60+ DIFFERENT parts to create and I would really hate to see somoeone break something expensive in there.

Here is what I would like to do:

Create a central server for storing/validating the username(s), password(s) entered through the client terminal connected to the door of the facility.

Allow 3 failed login attempts before completely disabling the terminal for 1 hour (86400 seconds).

I would like to maintin the current structure of the system in that, it still requires a match of BOTH variables to proceed through the the hall into the facility. Below is a copy of the current code running on that door. Please feel free to comment / corrent / suggest changes in the current design. ANY help with this project is MUCH appreciated. Thanks in advance.


--Disable Manual Termination
os.pullEvent = os.pullEventRaw
--Declare Variables
local username;
local password;
id = "Crysys";
key = "thewhiterabbit";
override= "6552180573395";
alarmSide = "back";
alarmTimeout = "3";
doorSide = "bottom";
doorTimeout = "5";
errorTimeout = "1";
delay = "1";
--Display Data Requests, Get Inputs
term.clear();
term.setCursorPos(1,1);
print("Nuclear Facility - Access Verification Required");
print("");
print("Username:");
term.setCursorPos(11,3);
username = read();
print("Password:");
term.setCursorPos(11,4);
password = read("*");
--Handle Inputs
if username == id and password == key then
term.clear();
term.setCursorPos(1,1);
print("Access Granted");
rs.setOutput(alarmSide, true);
sleep(alarmTimeout);
rs.setOutput(alarmSide, false);
sleep(delay);
rs.setOutput(doorSide, true);
sleep(doorTimeout);
rs.setOutput(doorSide, false);
os.reboot();
elseif username == id and password == override then
term.clear();
term.setCursorPos(1,1);
print("Maintanence Mode ENABLED");
print("");
else
print("Login FAILED");
sleep(errorTimeout);
os.reboot();
end
RunasSudo-AWOLindefinitely #2
Posted 13 January 2013 - 09:39 PM
One thing I'd suggest is not storing the password as plaintext.
There are plenty of hashing algorithms for Lua if you Google hard enough (I'd recommend this version of SHA-1)
That way, if someone got a hold of your source code, they wouldn't be able to see the password.
Nubz_Unite #3
Posted 29 January 2013 - 05:43 PM
Cool system ill try it out my question is what if I want to add a second user?
DaRc #4
Posted 02 March 2013 - 10:31 PM
I am still pretty new to LUA, hence posting on the forums for help. I asked if there is a way to get this same basic concept to read from a seperate file filled with users/passwords or something similar, and wasn't given a reply. I accidently ended up with two topics on this when I first started because I thought this original topic glitched. I have received some help on the matter, but not regarding multiple users being added. Still would love to get that part working, some friends thought a username/password door (for securied facility) or a username password simulated terminal (such as what would be in an office) was actually really cool. I had watched tons of videos on youtube for computercraft password locks of all sorts, hadn't seen one like this before. My concept design is pretty crude and needs lots of tuning, hope to get it fine tuned and released as an official design for people to use.

If anyone has any thoughts ont he matter please feel free to chime in, always willing to learn something new! Thanks in advance.