Jump to content




Password Protected Computer | Nynoray

utility computer lua

12 replies to this topic

#1 nynoray

  • New Members
  • 24 posts

Posted 12 July 2012 - 11:38 PM

Hey guy, this is my program that makes your computer password protected.
I'm new with lua so the coding isn't very complex, even though you don't need complex coding to do this.

First off let's learn about this. (This is basics for the program, most people will be able to skip through most of this and still use the program fully)

The code:


os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)
print("Borta Computer Security 1.1")
print("UserName: Nynoray")
write("Password: ")
function pass()
t = io.read()
if t == "rhino" then
print ("Access Granted.")
sleep(2)
term.clear()
term.setCursorPos(1,1)
else
print ("Incorrect Login Details.")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("Borta Computer Security 1.1")
print("UserName: Nynoray")
write("Password: ")
pass()
end
end
pass()



Have this code as the startup program on your computer. (If this code doesn't work let me know because it is a copying error I would have made.)

You can change the prints to customize the interface, but, if that print/write occurs later in the coding the two should match. (You could just change the whole interface if you want more tricky though.)


Here is the main interface, it shows after the computer boots and after you enter an incorrect password.


Posted Image


This is the interface that shows up when you enter an incorrect password, it reverts to the main interface after two seconds.


Posted Image


This is the interface that shows up when you enter the correct password, after one second it clears the screen and you have access to the computer.


Posted Image


There are ways to get past this lock lock like almost every one I know about. If you boot it from a floppy you can get past the password, A way to prevent this is if you make it so only one side of the computer is open and the other sides can't be opened by an intruder. This would be done by surrounding the surface in blocks that only you (and friends maybe) can destroy. You would need access to bedrock or be able to protect blocks with a plugin on the server. That way if they put the disk drive on the computer, they can not click the computer (if they have more person they may be able to do this though). The computer never reboots before you get the password correct, so you can't do something like get the wrong pass then put the disk drive to load the floppy.


That's all i think, if there is any info you want on it, ask and I can add it.



#2 glopso

  • New Members
  • 15 posts

Posted 12 July 2012 - 11:53 PM

If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 13 July 2012 - 12:27 AM

This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
while true do
	term.clear()
	term.setCursorPos(1,1)
	print("Borta Computer Security 1.1")
	print("UserName: Nynoray")
	write("Password: ")
	if read("*") == "rhino" then
		print("Access Granted.")
		sleep(2)
		term.clear()
		term.setCursorPos(1,1)
		break
	else
		print ("Incorrect Login Details.")
		sleep(1)
	end
end
os.pullEvent = oldPull


#4 nynoray

  • New Members
  • 24 posts

Posted 13 July 2012 - 01:20 AM

View Postglopso, on 12 July 2012 - 11:53 PM, said:

If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

Possibly, but you would also need to insert the floppy into the disk drive and that might not be possible if the disk drive hasn't showed up.

#5 nynoray

  • New Members
  • 24 posts

Posted 13 July 2012 - 01:44 AM

View PostLyqyd, on 13 July 2012 - 12:27 AM, said:

This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

Yea I didn't know another way to make it not stop the startup if the password was wrong. I am trying to learn the lua used for cc but I'll be pretty bad at it for a bit :)/>.

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 13 July 2012 - 04:53 AM

View Postnynoray, on 13 July 2012 - 01:44 AM, said:

View PostLyqyd, on 13 July 2012 - 12:27 AM, said:

This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

Yea I didn't know another way to make it not stop the startup if the password was wrong. I am trying to learn the lua used for cc but I'll be pretty bad at it for a bit :)/>.

Well, the way you were doing it would work, it would just cause problems if someone kept trying wrong passwords. The version I posted above keeps them in the loop ("while true do" is the start of the loop) until the correct password is put in, then the "break" instruction exits the loop.

#7 nynoray

  • New Members
  • 24 posts

Posted 13 July 2012 - 05:27 AM

View PostLyqyd, on 13 July 2012 - 04:53 AM, said:

View Postnynoray, on 13 July 2012 - 01:44 AM, said:

View PostLyqyd, on 13 July 2012 - 12:27 AM, said:

This is a somewhat improved version. It is always a bad idea to try to create an infinite loop through recursion; you'll eventually overflow your stack, except in very limited circumstances. You also should be using a read("*") call for passwords, not io.read().

Yea I didn't know another way to make it not stop the startup if the password was wrong. I am trying to learn the lua used for cc but I'll be pretty bad at it for a bit :)/>.

Well, the way you were doing it would work, it would just cause problems if someone kept trying wrong passwords. The version I posted above keeps them in the loop ("while true do" is the start of the loop) until the correct password is put in, then the "break" instruction exits the loop.

Yea, but could you have the 'while true do' when there is multiple options other then else.

I'll give an example here but the coding might fail because I'm just writing this up now without testing, but the main point: would doing 'while true do' for each option (or something like that) work also. or is this code just fine.

print("diamond:1, iron:2")
function item()
t = io.read()
if t == "1" then
	  rs.setOutput("right", true)
	  sleep(1)
	  rs.setOutput("right", false)
	  os.reboot()
	  end
if t == "2" then
	  rs.setOutput("left", true)
	  sleep(1)
	  rs.setOutput("left", false).
	  os.reboot()
	  end
else
				-- dont remember this part exactly so its going to be shit
item()
end
end
item()
			  --probably made an infinite loop if they dont put 1 or 2 but you should know thats not an option

i had a comp running this (the script that works, this is just an example that prob doesn't work) connected to dispensers and worked.
tried making it use 'while true do' and it didnt work. (probably my errors)

was doing this on phone so there will be a lot of grammar errors, sorry

#8 glopso

  • New Members
  • 15 posts

Posted 13 July 2012 - 05:28 AM

View Postnynoray, on 13 July 2012 - 01:20 AM, said:

View Postglopso, on 12 July 2012 - 11:53 PM, said:

If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

Possibly, but you would also need to insert the floppy into the disk drive and that might not be possible if the disk drive hasn't showed up.
Oh yeah. My bad

#9 nynoray

  • New Members
  • 24 posts

Posted 13 July 2012 - 05:30 AM

View Postglopso, on 13 July 2012 - 05:28 AM, said:

View Postnynoray, on 13 July 2012 - 01:20 AM, said:

View Postglopso, on 12 July 2012 - 11:53 PM, said:

If the server is lagging enough you could probably shift-right click and then right-click again before the block appears, bypassing the security.

Possibly, but you would also need to insert the floppy into the disk drive and that might not be possible if the disk drive hasn't showed up.
Oh yeah. My bad


yea but if you had 2 people one could right click the comp, the other add disk drive and floppy and the 1st will still be in comp,(atleast i think)
then just ctrl+r

#10 Disy

  • New Members
  • 9 posts

Posted 15 July 2012 - 03:04 AM

I have a question, I decided to mix Lyqyd, and your codes together, and I got a great design. The only problem
being that if you get the password correct the computer screen will now exit out of the program. How would I go
about creating it so that it will just reboot after getting the password correct?

#11 nynoray

  • New Members
  • 24 posts

Posted 06 September 2012 - 09:08 PM

View PostDisy, on 15 July 2012 - 03:04 AM, said:

I have a question, I decided to mix Lyqyd, and your codes together, and I got a great design. The only problem
being that if you get the password correct the computer screen will now exit out of the program. How would I go
about creating it so that it will just reboot after getting the password correct?
Sorry for taking like 3 months to respond but I haven't been playing tekkit a lot getting back into it now... anyways, It's probably answered already but i'll try anyways :D/>. I couldn't be sure without seeing your coding for it, but since his coding was a slightly more efficient version so mixing the two might end up with some parts missing. You could try using only one of them or I could maybe find out if I could see your code.

#12 yungskittlez

  • New Members
  • 1 posts

Posted 15 February 2013 - 07:53 PM

i have the while looped code and when i enter the correct password i am still stuck in a loop help?

#13 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 16 February 2013 - 04:08 AM

*sigh*
Don't raise threads that are months old from the dead. If you need help with code, there is a section in the Ask A Pro area for that. Locked.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users