I'm making a bunch of new programs which are linked together so that all changes can be tracked and also controlled from a single point. Obviously if that's the aim, the computers must be secure right? Of course :D/> Read below if you want to know more.
Explanation of program interaction:
The front end client works by the user entering in their login details, it then packages that info up nice and neat and sends it to the designated server. Once that's done, the server check the username and password and sends back a response of "ADMIN" or "USER", if the password or username is wrong then it simply doesn't send anything back and ignores it. Depending on the result of the authentication, you either gain access to the Admin Menu, the User Menu or you get chucked back into the log in page. Since no passwords are stored on the front end, it means a) you don't have to place usernames and passwords everywhere and B)/> no risk of them getting the information from the front end. The future aim is to next code in a feature that means that the server controls everything, however it's the user terminals that 'ask' for things to happen, and if it isn't authenticated, then it is ignored.
Just be advised that the programs that I will be writing will most likely be for the FTB client because there are more mods which can work with the computers, e.g. bundled cables.
I have started posting components below :D/>
If anyone wants some help with their own programs or has any good ideas for me to add then please comment :P/>
Thanks!
Stirfry Noodles
[ 11th of June 2013 ]
Just a little update, there is code a few posts below, however all of them has been majorly upgraded. I had one of those moments where you realize there is a much better and simpler way of doing something… Scary.
Will post the updated version soon, many differences, and so far, it works. More updates are to come though, trying to implement a more secure authentication system for Front End controls.
[ 12th of June 2013 ]
More updates posted…
ALL PROGRAMS ARE WRITTEN BY MYSELF.
IF YOU USE IT, PLEASE SAY SO :)/>
THERE ARE INCOMPLETE SECTIONS, I'M NOT DONE … YET. :P/>
The Roaming Login Server
Spoiler
--[[ Door Roaming Login Server ]]--
--[[ Login Details ]]--
tUsernames = { -- Add users to the list, make sure there is the corresponding password and user status in the correct index
"StirfryNoodles",
"99Doomsday",
"CyrusShock",
"ANYONE :D/>/>/>/>/>/>/>/>"
}
tPasswords = {
"12345",
"54321",
"13524",
"AND ANY PASSWORD"
}
tUserStatus = {
"ADMIN",
"ADMIN",
"USER",
"SET STATUS HERE :D/>/>/>/>/>/>/>/>"
}
tAcceptedSenders = { 1, 3, 4, 5 }
--[[ Local Variables ]]--
bRunning = true -- Main loop controller ( boolean value )
localComputerID = os.getComputerID()
activityLogServerID = 0 -- Change the ID shown here to the one of the Activity Log Server
sWirelessModemSide = "right" -- Change to the side that has the wireless modem... Obviously
statusReport = "User logged into Door Server: "..localComputerID
--[[ Local Functions ]]--
function clearScreen()
term.clear()
term.setCursorPos( 1,1 )
end
function IsAcceptableTerminal(nTerminalID)
for i = 1, #tAcceptedSenders do
if tAcceptedSenders[i] == nTerminalID then
return true
end
end
return false
end
function ValidateUser(sUser, sPass)
retVal = "";
for i = 1, #tUsernames do
if tUsernames[i] == sUser then
if tPasswords[i] == sPass then
retVal = tUserStatus[i]
break
end
end
end
return retVal
end
function sendReport()
tTable = { sUserType, tCredentials[1], "User has logged on" }
sTable = textutils.serialize( tTable )
rednet.send( activityLogServerID, sTable )
end
--[[ Program Start ]]--
-- No os.pullEvent() = os.pullEventRaw() because this is a server, you may need to shut it down manually.
while bRunning do -- Main program loop, it doesn't end. At all. Use Ctrl-T to terminate it. :)/>/>/>/>/>/>/>/>
clearScreen()
rednet.open( sWirelessModemSide )
print( "Login Server Online at Terminal: "..localComputerID )
print( "Accepting transmissions from: " )
for nIndex = 1, #tAcceptedSenders do
write( tAcceptedSenders[nIndex]..", " )
end
initialSenderID, sentCredentials = rednet.receive()
term.setCursorPos( 1,5 )
while true do
if IsAcceptableTerminal(initialSenderID) then
tCredentials = textutils.unserialize(sentCredentials)
print ( "Username = " .. tCredentials[1] .. " with Passowrd = " .. tCredentials[2] )
sUserType = ValidateUser(tCredentials[1], tCredentials[2])
print ("UserType = " .. sUserType)
rednet.send(initialSenderID, sUserType)
if sUserType == "ADMIN" or sUserType == "USER" then
sendReport()
end
initialSenderID, sentCredentials = rednet.receive()
end
end
end
Front End Client
Spoiler
--[[ Door Control Program ]]--
-- BUILD IN PROGRESS
--[[ Local Variables ]]--
bRunning = true -- DO NOT CHANGE THESE BOOLEAN VALUES. AT ALL. BIG MISTAKE.
bCheckForLockDown = true
bWaitingForUser = false
bInUserLoginScreen = false
bInPassLoginScreen = false
bInUserMenu = false
bInAdminMenu = false
bSystemFailSafe = true
local nTermWidth, nTermHeight = term.getSize()
sWirelessModemSide = "right" -- Change to the side of the wireless modem.
sBundledCableSide = "left" -- Change to the side of the bundled cable.
local lockDownRedstoneCheck = redstone.testBundledInput( sBundledCableSide, 16384 ) -- BTW that colour is red.
loginServerID = 2 -- Change server IDs to match their respective jobs.
activityLogServerID = 0
sLocalDoorCode = "D1" -- Change to the name of the appropriate door.
--[[ Local Functions ]]--
function clearScreen()
term.clear()
term.setCursorPos(1,1)
end
function printCentered( nStartHeight, sString )
term.setCursorPos( nTermWidth/2 - string.len( sString )/2 + 1, nStartHeight )
term.write( sString )
end
function printErrorMessage( sErrorCode )
term.clear()
term.setCursorPos( 1,1 )
print( "An unexpected error has occurred, please contact\nthe Network Administrator and quote the error code,\nso they can help solve your problem.\n\nSorry for any inconvenience.\n\nError Code: "..sErrorCode.."\nSysCon v1.1" )
sleep( 5 )
os.shutdown()
end
function SendStatusReport( sStatusToBeSent )
tTable = { sUserType, enteredUsername, sStatusToBeSent }
sTable = textutils.serialize( tTable )
rednet.send( activityLogServerID, sTable )
end
--[[ Program Start ]]--
clearScreen()
print( "Loading program, please wait..." )
sleep( 1 )
print( "Load complete." )
sleep( 0.5 )
clearScreen()
rednet.open( sWirelessModemSide )
print( "Rednet port opened on side: "..sWirelessModemSide )
sleep( 0.5 )
while bRunning do
while bCheckForLockDown do
clearScreen()
print( "Checking systems..." )
sleep( 0.5 )
while lockDownRedstoneCheck do -- This will actually need to do something in the future... Where in case of lock-down, only admins can access terminals.
clearScreen()
print( "Currently unstable..." )
-- SECTION INCOMPLETE
end
print( "Check complete. Starting core functions." )
sleep( 1 )
bCheckForLockDown = false
-- bWaitingForUser = true
bInUserLoginScreen = true
end
while bWaitingForUser do -- This section of code is curently unused as I can't seem to clear the buffer of the os.pullEvent( "key" )
clearScreen()
printCentered( 9, "Press 'L' To Login" )
printCentered( 12, "** WARNING: Roaming Logon Enabled **" )
local sEvent, lKey = os.pullEvent( "key" )
if lKey == keys.l then
bInUserLoginScreen = true
bWaitingForUser = false
end
end
while bInUserLoginScreen do
clearScreen()
printCentered( 3, "Enter Username then Press Enter" )
printCentered( 5, "Enter 'Q' into Username to Quit" )
printCentered( 8, "############################" )
printCentered( 9, "# Username: #" )
printCentered( 10, "############################" )
printCentered( 11, "# Password: #" )
printCentered( 12, "############################" )
printCentered( 14, "** WARNING: Roaming Logon Enabled **" )
term.setCursorPos( nTermWidth/2 - string.len( "# Username: #" )/2 + 12, 9 )
enteredUsername = read()
if enteredUsername == "q" then
bInUserLoginScreen = false
bRunning = false
os.shutdown()
elseif enteredUsername == "Q" then
bInUserLoginScreen = false
bRunning = false
os.shutdown()
elseif enteredUsername == "756312746815634" then
clearScreen()
print( "Machine debug overide key detected, please wait..." )
print( "Stopping processess..." )
sleep( 1 )
print( "Done." )
sleep( 1.5 )
print( "WARNING: SYSTEM IS NOW VULNERABLE.\n PLEASE REBOOT WHEN FINISHED." )
print( "WARNING: ACTIVITY LOG HAS BEEN NOTIFIED." )
sleep( 1 )
tTable = { "SYSTEM", "TERMINAL", "MACHINE HAS ENTERED DEBUG MODE." }
sTable = textutils.serialize( tTable )
rednet.send( activityLogServerID, sTable )
bInUserLoginScreen = false
bRunning = false
bSystemFailSafe = false
else
bInPassLoginScreen = true
bInUserLoginScreen = false
end
end
while bInPassLoginScreen do
term.setCursorPos( nTermWidth/2 - string.len( "# Password: #" )/2 + 12, 11 )
enteredPassword = read( "*" )
tCredentials = { enteredUsername, enteredPassword }
sCredentials = textutils.serialize(tCredentials)
rednet.send( loginServerID, sCredentials )
senderId, sUserType = rednet.receive()
if senderId == loginServerID then
print(sUserType)
if sUserType == "ADMIN" then
clearScreen()
bInAdminMenu = true
bInPassLoginScreen = false
print( "Authentication successful. Please wait." )
elseif sUserType == "USER" then
clearScreen()
bInUserMenu = true
bInPassLoginScreen = false
print( "Authentication successful. Please wait." )
else
printCentered( 16, "Authentication failed. Please try again." )
bInPassLoginScreen = false
bInUserLoginScreen = true
sleep( 1.5 )
end
end
end
while bInUserMenu do
clearScreen()
print( "Successfully got to User Menu." )
printCentered( 3, "Press the number to select option." )
term.setCursorPos( 17, 6 )
print( "[1] Open Doors" )
term.setCursorPos( 17, 7 )
print( "[2] Log Out" )
term.setCursorPos( 17, 8 )
print( "[3] Shutdown" )
local sEvent, nKey = os.pullEvent( "key" )
if nKey == 2 then
clearScreen()
print( "Option 1 has been selected." )
print( "Doors will open for 3 seconds, please wait..." )
print( "WARNING: Notifying Activity Log..." )
SendStatusReport( "User has opened door: " .. sLocalDoorCode )
sleep( 0.5 )
-- SECTION INCOMPLETE
-- Make doors open and stuff like that for 3 seconds
sleep( 3 )
print( "Auto-logout, logging out, please wait..." )
SendStatusReport( "User has logged out." )
sleep( 1.5 )
bInUserMenu = false
bCheckForLockDown = true
elseif nKey == 3 then
clearScreen()
print( "Logging out, please wait..." )
sleep( 1.5 )
bInUserMenu = false
bCheckForLockDown = true
SendStatusReport( "User has logged out." )
elseif nKey == 4 then
clearScreen()
print( "Shutting down, please wait..." )
SendStatusReport( "User has logged out." )
sleep( 1.5 )
bInUserMenu = false
bRunning = false
os.shutdown()
end
end
while bInAdminMenu do
clearScreen()
print( "Successfully got to Admin Menu." )
-- SECTION INCOMPLETE...
sleep( 2 )
end
end
while bSystemFailSafe do
printErrorMessage( "#001-A" )
end
print( "The program has terminated." )
Activity Log
Spoiler
--[[ Activity Log ]]--
--[[
Notes:
- Program is designed to run on a monitor for easy use and viewing.
-
]]--
--[[ Local Variables ]]--
bRunning = true
sWirelessModemSide = "right" -- Change modem side as required, default is "right" for testing purposes.
nWriteLineHeight = 2
tAcceptedSenders = { 1, 2, 3, 4 } -- Change to match accepted senders
--[[ Local Functions ]]--
function printStatus()
local t = os.time()
t = textutils.formatTime( t, true )
print( "[ " .. t .. " ] >> " .. tStatusReport[1] .. "-" .. tStatusReport[2] .. "; Terminal: " .. initialSenderID )
print( " >> " .. tStatusReport[3] )
end
function clearScreen()
term.clear()
term.setCursorPos(1,1)
end
function IsAcceptableTerminal(nTerminalID)
for i = 1, #tAcceptedSenders do
if tAcceptedSenders[i] == nTerminalID then
return true
end
end
return false
end
--[[ Program Start ]]--
clearScreen()
print("")
while bRunning do
x, y = term.getCursorPos()
term.setCursorPos( 1, 1 )
print( "Activity Log Server Online, Hold Ctl-T to Quit" )
term.setCursorPos(x, y)
rednet.open( sWirelessModemSide )
initialSenderID, sentStatusReport = rednet.receive()
if IsAcceptableTerminal( initialSenderID ) then
tStatusReport = textutils.unserialize( sentStatusReport )
printStatus()
nWriteLineHeight = nWriteLineHeight + 2
end
end
SFND.