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

Terminal Lock Admin Bypass Not Working

Started by Mr_Programmer, 14 February 2014 - 06:58 PM
Mr_Programmer #1
Posted 14 February 2014 - 07:58 PM
hello,

i have this code that im working on but im strugling on getting just 1 part to work.
The admin bypass doesnt work, i have no errors but if its wrong (the password) then its ment to reboot, but it doesnt it justs starts again, like starts from the top of the "while true do" loop…

any help on this would be amazing, heres my code

——————-Variables———————–

local side = "back" –Redstone Output for Alarm System
local username = "Kendall" –Username
local admin = "Admin" –OS Will Defualt Run "Luaide", Admin Will Bypass This Feature
local password = "kendall18" –Password
local admin_pass = "computercraft" –Admin Password (Can Change Its To Anything You Want)
local admin_Bypass_Code = "16384512" –Bypass code (extra security)
local sleeptime = 4
c_oss = 16 –Operating System (QuarantineOS v1.0.1)
c_atps = 512 –Attempts Left
c_dsp = 4 –Display (Username and Password)
c_icr = 16384 –Fail(Username & Password Incorrect)
OSS = "Quarantine_Security v1.0.1" –Top (Operating System)
Attempts = "Attempts Left (2)" – Top Right (Attempts Left)
Prgm = "lock" –Use for (shell.run) Change Variable In Each Program
correctPgrm = "luaide" –Change this to the program that normal usernames and passwords run
correctPgrmAdmin = "bypass" –Change this to what the admin username and password run's if correct

function username_password()
term.setCursorPos(1,3)
term.setTextColour(c_dsp)
print("Username: ")
term.setCursorPos(1,4)
print("Password: ")
term.setCursorPos(1,6)
print("Bypass Code: ")
end
—————————————————

while true do
term.clear()
term.setCursorPos(1,1)
term.setTextColour(c_oss)
print(OSS)
term.setCursorPos(35,1)
term.setTextColour(c_atps)
print(Attempts)
username_password()
term.setCursorPos(10,3)

local input = read()

if input == username then
term.setCursorPos(10,4)
elseif input == admin then
term.setCursorPos(10,4)
else
term.clear()
term.setCursorPos(1,1)
term.setTextColour(c_oss)
print(OSS)
term.setCursorPos(35,1)
term.setTextColour(c_atps)
print(Attempts)
term.setCursorPos(18,3)
term.setTextColour(c_icr)
print("Username Incorrect!")
sleep(sleeptime)
os.reboot()
end

local input_ = read("*")

if input_ == password then
shell.run(correctPgrm)
elseif input_ == admin_pass then
–term.setCursorPos(13,6)
shell.run("admin")
else
term.clear()
term.setCursorPos(1,1)
term.setTextColour(c_oss)
print(OSS)
term.setCursorPos(35,1)
term.setTextColour(c_atps)
print(Attempts)
term.setCursorPos(18,3)
term.setTextColour(c_irc)
print("Username Incorrect!")
sleep(sleeptime)
os.reboot()
end
———————————————————————————————— under this line is for testing, apart from the end right at the bottom…
local input__ = read("*")

if input__ == admin_Bypass_Code then
shell.run("bypass_admin")
else
os.reboot()
end
end
Bomb Bloke #2
Posted 15 February 2014 - 01:37 AM
This script first asks for a username, and if it's not recognised, it reboots.

Assuming the username was recognised, it'll next ask for a password. If the regular user's password was entered it'll run the correctPgrm script ("luaide"), or if the the admin user's password was entered it'll run the script called "admin". Note that it makes no difference here which username was entered during the first step. If an unrecognised password is entered, the script should again trigger a reboot.

You should only be expected to enter the "bypass" code if a recognised username was entered and a recognised password was entered and the other script that was executed as a result has some way of finishing (if that runs another script which runs another script etc then this script won't ever get to continue). Note that if a script runs itself again, that doesn't count as "finishing" - the first instance will sit and wait for the second one to finish up completely.
Mr_Programmer #3
Posted 18 February 2014 - 09:03 AM
This script first asks for a username, and if it's not recognised, it reboots.

Assuming the username was recognised, it'll next ask for a password. If the regular user's password was entered it'll run the correctPgrm script ("luaide"), or if the the admin user's password was entered it'll run the script called "admin". Note that it makes no difference here which username was entered during the first step. If an unrecognised password is entered, the script should again trigger a reboot.

You should only be expected to enter the "bypass" code if a recognised username was entered and a recognised password was entered and the other script that was executed as a result has some way of finishing (if that runs another script which runs another script etc then this script won't ever get to continue). Note that if a script runs itself again, that doesn't count as "finishing" - the first instance will sit and wait for the second one to finish up completely.
yes but how do it get the admin part to work, everything else works fine
Lyqyd #4
Posted 18 February 2014 - 10:46 AM
You need to adjust the logic of the program (which Bomb Bloke helpfully walked through and explained for you) to actually do what you expect it to do.
surferpup #5
Posted 18 February 2014 - 11:00 AM
Other than your logic, the reason the current program fails is that in the else block of your check password section, you have transposed a variable. You wrote:


term.setTextColour(c_irc)

The correct variable is c_icr not c_irc.

I also agree with what [member='Bomb Bloke'] and [member='Lyqyd'] have suggested.
Edited on 18 February 2014 - 10:01 AM
Bomb Bloke #6
Posted 18 February 2014 - 04:19 PM
You need to adjust the logic of the program (which Bomb Bloke helpfully walked through and explained for you) to actually do what you expect it to do.
… and if you want any more help then that, you'll have to actually describe to us how what the script does differs from what you want. And no, telling us you want it to "work" isn't saying much - be specific as to its current behaviour and desired behaviour.

The assumption I'm working on is that one or more of the "luaide", "admin" or "bypass_admin" scripts have something to do with it - your script calls these, but I've no idea what they do. I can tell you that at least one of these scripts will start before this script gets to loop up to the top of its "while" block, so if they don't end (or worse, specifically try to call this script again instead of ending…), then that's likely your issue.

Regarding the colours, bear in mind that you don't need to type the numbers into your script at all. You can just enter the pre-defined names "colours.yellow", "colours.cyan", "colours.magenta" etc direct from the colours API and it'll pull them from there for you.
surferpup #7
Posted 18 February 2014 - 04:44 PM
Also, in the future, please learn how to use code tags when you post your code in this forum, so that your code looks like this:


while true do
  --Golly, here is my code
end

To do so, simply type [code] at the start of your code, and [/code] at the end of your code (note the use of square brackets). This makes it much easier for us to help you resolve your issues (following good indenting rules is also helpful both for you and for us :)/> )
Edited on 18 February 2014 - 03:46 PM