ViperSecurity
Secure locking with multiple customisable settings
Can be terminated with a seperate password to access the computer
Can be used wirelessly between two seperate computers
Locks with either passwords or floppy disks
Locks out hackers after 3 failed tries
Locks out hackers after rebooting
Displays message to a monitor
Locks doors
Screenshots
Spoiler
How to Layout the Computers
Spoiler
It is possible to hack this system by using a disk with a startup program installed
However, you can stop this by doing the following:
Password Lock
To prevent hackers hacking your password lock, simply remove any disk drives adjacent to the computer
Example:
Floppy Disk Lock
Now here comes a problem. With a floppy disk lock, you can't just remove all the disk drives since it requires one
What you can do instead to prevent hackers with the Floppy Disk Lock is this:
With this setup, if the computer is rebooted it will run the ViperSecurity disk every time
Update Log
Spoiler
1.1.0
Added monitor display (works best with 1x1 monitors)
Added wireless option
Fixed several bugs
1.0.3
Added functions
Added customisation of maximum attempts and lock time
Added terminated window
1.0.2
Fixed a hacking method
It will now only eject the disk with the password on it
1.0.1
Fixed lock window resizing
1.0.0
First release
Code
Spoiler
--Functions
function savePass(a,b,c,d)
passStore = fs.open(".ViperSecurity/passwords.vsec","a")
passStore.writeLine(a)
passStore.writeLine(:(/>/>
passStore.writeLine(c)
passStore.writeLine(d)
passStore.close()
end
function openPass()
passStore = fs.open(".ViperSecurity/passwords.vsec","r")
pass = passStore.readLine()
tpass = passStore.readLine()
FDES = passStore.readLine()
eject = passStore.readLine()
passStore.close()
end
function saveWirelessData(a,:D/>/>
wirelessDataStore = fs.open(".ViperSecurity/wireless.vsec","a")
wirelessDataStore.writeLine(a)
wirelessDataStore.writeLine(B)/>/>
wirelessDataStore.close()
end
function openWirelessData()
wirelessDataStore = fs.open(".ViperSecurity/wireless.vsec","r")
connectedComputerString = wirelessDataStore.readLine()
wirelessReceiver = wirelessDataStore.readLine()
wirelessDataStore.close()
connectedComputer = tonumber(connectedComputerString)
end
function power()
redstone.setOutput("right",true)
redstone.setOutput("front",true)
redstone.setOutput("left",true)
redstone.setOutput("back",true)
redstone.setOutput("top",true)
redstone.setOutput("bottom",true)
os.sleep(3)
redstone.setOutput("right",false)
redstone.setOutput("front",false)
redstone.setOutput("left",false)
redstone.setOutput("back",false)
redstone.setOutput("top",false)
redstone.setOutput("bottom",false)
end
function ejectDisk(a)
if disk.getMountPath("top") ~= nil then
if fs.exists(disk.getMountPath("top").."/"..a) then
disk.eject("top")
end
end
if disk.getMountPath("bottom") ~= nil then
if fs.exists(disk.getMountPath("bottom").."/"..a) then
disk.eject("bottom")
end
end
if disk.getMountPath("front") ~= nil then
if fs.exists(disk.getMountPath("front").."/"..a) then
disk.eject("front")
end
end
if disk.getMountPath("right") ~= nil then
if fs.exists(disk.getMountPath("right").."/"..a) then
disk.eject("right")
end
end
if disk.getMountPath("back") ~= nil then
if fs.exists(disk.getMountPath("back").."/"..a) then
disk.eject("back")
end
end
if disk.getMountPath("left") ~= nil then
if fs.exists(disk.getMountPath("left").."/"..a) then
disk.eject("left")
end
end
end
function lockComputer()
timeLocked = timeLocked - 1
term.clear()
term.setCursorPos(1,7)
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors(" Incorrect")
printMonitors(" password")
printMonitors("")
printMonitors(" Locked for "..timeLocked)
printMonitors(" seconds")
print(" ,-========================-,")
print(" | Incorrect password |")
print(" | |")
print(" | |")
if timeLocked < 10 then
print(" | Locked for "..timeLocked.." seconds |")
elseif timeLocked < 100 then
print(" | Locked for "..timeLocked.." seconds |")
elseif timeLocked < 1000 then
print(" | Locked for "..timeLocked.." seconds |")
end
print(" |__________________________|")
os.sleep(1)
end
function lockComputerReboot()
timeLocked = lockTime
while timeLocked > 0 do
term.clear()
term.setCursorPos(1,7)
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors(" OS Rebooted")
printMonitors("")
printMonitors(" Locked for "..timeLocked)
printMonitors(" seconds")
print(" ,-========================-,")
print(" | OS Rebooted |")
print(" | |")
print(" | |")
if timeLocked < 10 then
print(" | Locked for "..timeLocked.." seconds |")
elseif timeLocked < 100 then
print(" | Locked for "..timeLocked.." seconds |")
elseif timeLocked < 1000 then
print(" | Locked for "..timeLocked.." seconds |")
end
print(" |__________________________|")
timeLocked = timeLocked - 1
os.sleep(1)
end
end
function saveLockData(a,B)/>/>
lockTimeStore = fs.open(".ViperSecurity/locktime.vsec","a")
lockTimeStore.writeLine(a)
lockTimeStore.writeLine(B)/>/>
lockTimeStore.close()
end
function openLockData()
lockTimeStore = fs.open(".ViperSecurity/locktime.vsec","r")
lockTimeString = lockTimeStore.readLine()
maxTriesString = lockTimeStore.readLine()
lockTimeStore.close()
lockTime = tonumber(lockTimeString)
maxTries = tonumber(maxTriesString)
end
function getMonitors()
if peripheral.getType("top") == "monitor" then
x,y = monTop.getSize()
textScale = x/2
monTop.setTextScale(textScale)
monTop = peripheral.wrap("top")
monTopExists = true
end
if peripheral.getType("bottom") == "monitor" then
monBottom = peripheral.wrap("bottom")
monBottomExists = true
x,y = monBottom.getSize()
textScale = x/2
monBottom.setTextScale(0.5)
end
if peripheral.getType("front") == "monitor" then
x,y = monFront.getSize()
textScale = x/2
monFront.setTextScale(textScale)
monFront = peripheral.wrap("front")
monFrontExists = true
end
if peripheral.getType("right") == "monitor" then
x,y = monRight.getSize()
textScale = x/2
monRight.setTextScale(textScale)
monRight = peripheral.wrap("right")
monRightExists = true
end
if peripheral.getType("back") == "monitor" then
x,y = monBack.getSize()
textScale = x/2
monBack.setTextScale(textScale)
monBack = peripheral.wrap("back")
monBackExists = true
end
if peripheral.getType("left") == "monitor" then
x,y = monLeft.getSize()
textScale = x/2
monLeft.setTextScale(textScale)
monLeft = peripheral.wrap("left")
monLeftExists = true
end
end
function printMonitors(a)
if monTopExists == true then
x,y = monTop.getCursorPos()
monTop.setCursorPos(1,y+1)
monTop.write(a)
end
if monBottomExists == true then
x,y = monBottom.getCursorPos()
monBottom.setCursorPos(1,y+1)
monBottom.write(a)
end
if monFrontExists == true then
x,y = monFront.getCursorPos()
monFront.setCursorPos(1,y+1)
monFront.write(a)
end
if monRightExists == true then
x,y = monRight.getCursorPos()
monRight.setCursorPos(1,y+1)
monRight.write(a)
end
if monBackExists == true then
x,y = monBack.getCursorPos()
monBack.setCursorPos(1,y+1)
monBack.write(a)
end
if monLeftExists == true then
x,y = monLeft.getCursorPos()
monLeft.setCursorPos(1,y+1)
monLeft.write(a)
end
end
function clearMonitors()
if monTopExists == true then
monTop.setCursorPos(1,0)
monTop.clear()
end
if monBottomExists == true then
monBottom.setCursorPos(1,0)
monBottom.clear()
end
if monFrontExists == true then
monFront.setCursorPos(1,0)
monFront.clear()
end
if monRightExists == true then
monRight.setCursorPos(1,0)
monRight.clear()
end
if monBackExists == true then
monBack.setCursorPos(1,0)
monBack.clear()
end
if monLeftExists == true then
monLeft.setCursorPos(1,0)
monLeft.clear()
end
end
function openModem()
rednet.open("top")
rednet.open("bottom")
rednet.open("front")
rednet.open("right")
rednet.open("back")
rednet.open("left")
end
function wirelessInput()
openModem()
print("Connecting...")
while connected ~= true do
rednet.broadcast("vipersecurityconnecting")
a,b,c = rednet.receive()
if b == "vipersecurityconnected" and a == connectedComputer then
print("Connected to computer "..a..", "..c.."m away.")
connected = true
end
end
end
function wirelessOutput()
openModem()
print("Waiting for connection...")
while connected ~= true do
a,b,c = rednet.receive()
if b == "vipersecurityconnecting" and a == connectedComputer then
rednet.send(a,"vipersecurityconnected")
connected = true
wirelessReceiver = "true"
end
end
end
function wirelessInputSetup()
openModem()
print("This computer's ID is "..os.computerID())
print("Connecting, check other computer")
while connected ~= true do
rednet.broadcast("vipersecurityconnecting")
a,b,c = rednet.receive(1)
if b == "vipersecurityconnected" then
print("Connected to computer "..a..", "..c.."m away.")
print("Do you want to use this connection? y/n")
yn = read()
if yn == "y" then
connectedComputer = a
connected = true
rednet.send(connectedComputer,"vipersecuritysuccess")
continue = true
saveWirelessData(connectedComputer,"true")
end
else
os.sleep(0.3)
end
end
end
function wirelessOutputSetup()
openModem()
print("This computer's ID is "..os.computerID())
print("Connecting...")
while connected ~= true do
a,b,c = rednet.receive(1)
if b == "vipersecurityconnecting" then
print("Connected to computer "..a..", "..c.."m away.")
print("Do you want to use this connection? y/n")
yn = read()
if yn == "y" then
connectedComputer = a
print("Please finish setup on the other computer")
while success ~= true do
rednet.send(connectedComputer,"vipersecurityconnected")
a,b,c = rednet.receive(1)
if a == connectedComputer and b == "vipersecuritysuccess" then
success = true
print("Success!")
saveWirelessData(connectedComputer,"true")
connected = true
continue = false
correctInput = true
end
end
end
else
os.sleep(0.2)
end
end
end
--Setup
if fs.exists(".ViperSecurity/passwords.vsec") == false and fs.exists(".ViperSecurity/wireless.vsec") == false then
fs.makeDir(".ViperSecurity")
correctInput = false
while correctInput == false do
passSet = "false"
print("Do you want to use wireless? y/n")
yn = read()
if yn == "y" then
print("To use wireless, you will need two computers,")
print("one into which you will enter the password/disk")
print("and another which will receive the password and")
print("power redstone or allow access if it's correct.")
print("Both need a modem attached.")
print("Press enter to continue")
read()
print("Do you want:")
print("1. To enter the password/disk into this computer")
print("2. To have this computer receive the password")
numinput = read()
while correctInput2 ~= true do
if numinput == "1" then
wirelessInputSetup()
correctInput2 = true
elseif numinput == "2" then
wirelessOutputSetup()
correctInput2 = true
else
print("Please enter either 1 or 2")
end
end
else
connectedComputer = "-1"
wirelessReceiver = "false"
continue = true
end
if continue == true then
print("Would you like to:")
print("1. Use a password lock")
print("2. Use a floppy disk lock")
numinput = read()
if numinput == "1" or numinput == "2" then
while passSet == "false" do
print("Do you wish to set a password which can be")
print("used to power redstone on all sides of the")
print("computer? (e.g. Door locks) y/n")
yn = read()
if yn == "y" then
print("Enter your desired password (no spaces):")
pass = read()
passSet = "true"
else
pass = "false"
end
correctInput = true
print("Do you wish to set a password which can be")
print("used to terminate ViperSecurity and access")
print("the operating system? (Computer Lock) y/n")
yn = read()
if yn == "y" then
print("Enter termination password (no spaces):")
tpass = read()
passSet = "true"
else
tpass = "false"
end
if passSet == "false" then
print("You didn't set a password!")
os.sleep(1)
end
end
end
if numinput == "1" then
eject = false
FDES = "false"
lockTime = 60
maxTries = 3
enterPressed = false
while enterPressed == false do
term.clear()
term.setCursorPos(1,1)
print("After how many incorrect attempts do")
print("you want the computer to be locked?")
print("(Change with arrow keys and then press enter)")
if maxTries == 0 then
print("< Never lock the computer >")
elseif maxTries ~= 1 then
print("After < "..maxTries.." > incorrect attempts")
else
print("After < "..maxTries.." > incorrect attempt")
end
a,b = os.pullEvent()
if a == "key" then
if b == 203 and maxTries > 0 then
maxTries = maxTries - 1
elseif b == 205 and maxTries < 999 then
maxTries = maxTries + 1
elseif b == 28 then
enterPressed = true
end
end
end
enterPressed = false
while enterPressed == false do
term.clear()
term.setCursorPos(1,1)
if maxTries ~= 0 then
print("How long do you want the computer to be")
print("locked for after either "..maxTries.." incorrect attempts")
print("have been made or the computer is rebooted?")
print("(Change with arrow keys and then press enter)")
if lockTime ~= 1 then
print("For < "..lockTime.." > seconds")
else
print("For < "..lockTime.." > second")
end
else
print("How long do you want the computer to be")
print("locked for after the computer is rebooted?")
print("(Change with arrow keys and then press enter)")
if lockTime ~= 1 then
print("For < "..lockTime.." > seconds")
else
print("For < "..lockTime.." > second")
end
end
a,b = os.pullEvent()
if a == "key" then
if b == 203 and lockTime > 0 then
lockTime = lockTime - 1
elseif b == 205 and lockTime < 999 then
lockTime = lockTime + 1
elseif b == 28 then
enterPressed = true
end
end
end
saveLockData(lockTime,maxTries)
savePass(pass,tpass,FDES,eject)
print("Information stored! Starting ViperSecurity...")
os.sleep(1.5)
elseif numinput == "2" then
FDES = "true"
correctInput = true
print("Do you want the disk to be")
print("ejected automatically? y/n")
yn = read()
if yn == "y" then
eject = "true"
else
eject = "false"
end
savePass(pass,tpass,FDES,eject)
saveWirelessData(connectedComputer,wirelessReceiver)
print("To use the floppy disk entry system,")
print("create the file disk/"..pass)
print("and place a disk drive adjacent to")
print("the computer. When you place the disk")
print("in the drive the door will open.")
print("This will also work with a termination")
print("password if set.")
print("Press enter to continue")
read()
print("Information stored! Starting ViperSecurity...")
os.sleep(2)
else
print("Please enter either 1 or 2")
os.sleep(2)
end
reboot = false
end
end
end
--Variables
os.pullEvent = os.pullEventRaw
if fs.exists(".ViperSecurity/wireless.vsec") == true then
openWirelessData()
openModem()
end
if wirelessReceiver ~= "true" then
openPass()
if fs.exists(".ViperSecurity/locktime.vsec") == true then
openLockData()
end
getMonitors()
clearMonitors()
timeLocked = 0
tries = maxTries
end
--Floppy Disk
if FDES == "true" then
printMonitors("Enter floppy disk")
term.clear()
term.setCursorPos(1,8)
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors(" Enter floppy")
printMonitors(" disk")
print(" ,-===============-,")
print(" |Enter floppy disk|")
print(" |_________________|")
while true do
if fs.exists("disk/"..pass) or fs.exists("disk2/"..pass) or fs.exists("disk3/"..pass) then
if eject == "true" then
ejectDisk(pass)
end
if fs.exists(".ViperSecurity/wireless.vsec") == true then
rednet.send(connectedComputer,"vipersecuritycorrectpass")
sleep(3)
else
power()
end
elseif fs.exists("disk/"..tpass) or fs.exists("disk2/"..tpass) or fs.exists("disk3/"..tpass) and tpass ~= "false" then
if eject == "true" then
ejectDisk(tpass)
end
if fs.exists(".ViperSecurity/wireless.vsec") == true then
rednet.send(connectedComputer,"vipersecuritycorrecttpass")
error()
else
power()
error()
end
end
os.sleep(0.2)
end
end
--Password
if reboot ~= false and wirelessReceiver == "false" then
lockComputerReboot()
end
if wirelessReceiver == "true" then
print("Waiting for password...")
while true do
a,b,c = rednet.receive()
if a == connectedComputer and b == "vipersecuritycorrectpass" then
power()
elseif a == connectedComputer and b == "vipersecuritycorrecttpass" then
power()
error()
end
end
else
while true do
term.clear()
term.setCursorPos(1,7)
if tries == maxTries then
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors("Enter Password")
print(" ,-========================-,")
print(" |This computer is protected|")
print(" | by ViperSecurity |")
print(" | |")
print(" | Enter password |")
print(" |__________________________|")
else
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors(" Incorrect")
printMonitors(" password")
printMonitors("")
printMonitors(" Attempts")
printMonitors(" remaining: "..tries)
print(" ,-========================-,")
print(" | Incorrect password |")
if tries < 10 then
print(" | Attempts remaining: "..tries.." |")
elseif tries < 100 then
print(" | Attempts remaining: "..tries.." |")
elseif tries < 1000 then
print(" | Attempts remaining: "..tries.." |")
end
print(" | |")
print(" | Enter password |")
print(" |__________________________|")
end
userInput = read("*")
if userInput == pass then
tries = maxTries
term.clear()
term.setCursorPos(1,7)
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors(" Correct!")
print(" ,-========================-,")
print(" | |")
print(" | Correct! |")
print(" | |")
print(" | |")
print(" |__________________________|")
if fs.exists(".ViperSecurity/wireless.vsec") == true then
rednet.send(connectedComputer,"vipersecuritycorrectpass")
sleep(3)
else
power()
end
elseif userInput == tpass and tpass ~= "false" then
term.clear()
term.setCursorPos(1,7)
clearMonitors()
printMonitors("")
printMonitors(" Protected by")
printMonitors("Viper Security")
printMonitors("")
printMonitors(" Terminated")
print(" ,-========================-,")
print(" | |")
print(" | Terminated |")
print(" | |")
print(" | |")
print(" |__________________________|")
if fs.exists(".ViperSecurity/wireless.vsec") == true then
rednet.send(connectedComputer,"vipersecuritycorrecttpass")
end
error()
elseif tries == 1 then
timeLocked = lockTime
tries = maxTries
while timeLocked > 0 do
lockComputer()
end
elseif tries ~= 0 then
tries = tries - 1
end
end
end
To install automatically put 'pastebin get 20Pj16bj startup' into a computer
If this doesn't work, try 'rom/programs/http/pastbin get 20Pj16bj startup'
This is my first program, so any constructive criticism and advice is greatly appreciated