Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --functions
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- print("NEOTERRA FOUNDATION")
- term.setTextColor(colors.white)
- print("Hosting On: ".."[Redacted]")
- end
- function Init()
- shell.run("fg")
- print("Initializing...")
- --open rednet
- local config = fs.open(".rnconfig","r").readAll()
- rednet.open(tostring(config))
- if rednet.isOpen() == false then
- print("Could Not Open Rednet, Check .rnconfig")
- else
- print("Rednet Opened On Channel "..os.computerID())
- end
- --end rn check
- -- user database
- print("Loading Username Database")
- if fs.exists(".users") == false then
- fs.open(".users","w").write('{"admin"}')
- print("Creating User Database")
- else
- print("User Database Found")
- end
- --end user database check
- -- password database check
- print("Loading Password Database")
- if fs.exists(".passwords") == false then
- fs.open(".passwords","w").write('{"admin"}')
- print("Creating Password Database")
- else
- print("Password Database Found")
- end
- --end password check
- end
- function load(name)
- local file = fs.open(name, "r")
- local data = file.readAll()
- file.close()
- return textutils.unserialise(data)
- end
- function Host()
- local log = fs.open(".log", "w")
- while true do
- local log = fs.open(".log", "a")
- local client,message,protocol = rednet.receive()
- --print(client.." : ".."[REDACTED]".." : "..protocol)
- log.writeLine(client..' '..message..' '..protocol)
- local cli = tonumber(client)
- i = tonumber(UID)
- --UID
- if protocol == "UID" then
- UID = message
- print("UID set to :"..message.." : "..client)
- rednet.send(cli, "confirm","response")
- end
- --USERNAME
- if protocol == "username" then
- if message == UserData[i] then
- print("Username: "..message.." : "..client)
- rednet.send(cli,"confirm","response")
- else
- printError("Username Rejected")
- rednet.send(cli, "denied","response")
- end
- end
- --PASSWORD
- if protocol == "password" then
- if message == PassData[i] then
- print("Password: ".."[REDACTED]".." : "..client)
- rednet.send(cli, "confirm","response")
- else
- printError("Password Rejected")
- rednet.send(cli, "denied","response")
- end
- end
- --SSH
- if protocol == "ssh" then
- local result = shell.run(message)
- rednet.send(client, result, "ssh")
- end
- log.close()
- end
- end
- --Start
- Init()
- print("Init Complete!")
- sleep(1)
- clear()
- UserData = load(".users")
- print("Loaded User Database!")
- sleep(1)
- PassData = load(".passwords")
- print("Loaded Password Database")
- sleep(1)
- clear()
- print("Hosting...")
- local UID = 1
- sleep(1)
- clear()
- Host()
- --test
- --print("Test:")
- --print(UserData[2])
- --print(PassData[2])
- --sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement