SHOW:
|
|
- or go back to the newest paste.
1 | --functions | |
2 | function clear() | |
3 | term.clear() | |
4 | term.setCursorPos(1,1) | |
5 | term.setTextColor(colors.red) | |
6 | print("NEOTERRA FOUNDATION") | |
7 | term.setTextColor(colors.white) | |
8 | print("Hosting On: ".."[Redacted]") | |
9 | end | |
10 | - | if fs.exists(".rnconfig") == false then |
10 | + | |
11 | - | local file = fs.open(".rnconfig","w") |
11 | + | |
12 | - | file.write("back") |
12 | + | |
13 | - | file.close() |
13 | + | shell.run("fg") |
14 | - | print(".rnconfig file generated") |
14 | + | |
15 | --open rednet | |
16 | local config = fs.open(".rnconfig","r").readAll() | |
17 | rednet.open(tostring(config)) | |
18 | if rednet.isOpen() == false then | |
19 | print("Could Not Open Rednet, Check .rnconfig") | |
20 | else | |
21 | print("Rednet Opened On Channel "..os.computerID()) | |
22 | - | sleep(1) |
22 | + | |
23 | --end rn check | |
24 | -- user database | |
25 | print("Loading Username Database") | |
26 | if fs.exists(".users") == false then | |
27 | fs.open(".users","w").write('{"admin"}') | |
28 | - | local unames = fs.open(".users","w") |
28 | + | |
29 | - | unames.write('{"admin"}') |
29 | + | |
30 | - | unames.close() |
30 | + | |
31 | end | |
32 | --end user database check | |
33 | -- password database check | |
34 | - | sleep(1) |
34 | + | |
35 | if fs.exists(".passwords") == false then | |
36 | fs.open(".passwords","w").write('{"admin"}') | |
37 | print("Creating Password Database") | |
38 | else | |
39 | print("Password Database Found") | |
40 | - | local passwds = fs.open(".passwords","w") |
40 | + | |
41 | - | passwds.write('{"admin", "password"}') |
41 | + | |
42 | - | passwds.close() |
42 | + | |
43 | ||
44 | function load(name) | |
45 | - | sleep(1) |
45 | + | local file = fs.open(name, "r") |
46 | local data = file.readAll() | |
47 | file.close() | |
48 | return textutils.unserialise(data) | |
49 | end | |
50 | ||
51 | function Host() | |
52 | - | local f = fs.open(name, "r") |
52 | + | local log = fs.open(".log", "w") |
53 | - | local data = f.readAll() |
53 | + | while true do |
54 | - | f.close() |
54 | + | local log = fs.open(".log", "a") |
55 | local client,message,protocol = rednet.receive() | |
56 | --print(client.." : ".."[REDACTED]".." : "..protocol) | |
57 | log.writeLine(client..' '..message..' '..protocol) | |
58 | local cli = tonumber(client) | |
59 | - | while true do |
59 | + | i = tonumber(UID) |
60 | --UID | |
61 | - | print(client..": "..message.." : "..protocol) |
61 | + | |
62 | - | local num = tonumber(client) |
62 | + | |
63 | - | local i = tonumber(UID) |
63 | + | print("UID set to :"..message.." : "..client) |
64 | rednet.send(cli, "confirm","response") | |
65 | end | |
66 | --USERNAME | |
67 | - | print("UID set to :"..message) |
67 | + | if protocol == "username" then |
68 | - | print(client) |
68 | + | |
69 | - | sleep(1) |
69 | + | print("Username: "..message.." : "..client) |
70 | - | rednet.send(num, "confirm") |
70 | + | rednet.send(cli,"confirm","response") |
71 | else | |
72 | printError("Username Rejected") | |
73 | - | if protocol == "username" then |
73 | + | rednet.send(cli, "denied","response") |
74 | - | |
74 | + | |
75 | end | |
76 | - | print("Username: "..message) |
76 | + | |
77 | - | rednet.send(num,"confirm") |
77 | + | |
78 | if message == PassData[i] then | |
79 | - | print("Username Rejected") |
79 | + | print("Password: ".."[REDACTED]".." : "..client) |
80 | - | rednet.send(num, "denied") |
80 | + | rednet.send(cli, "confirm","response") |
81 | else | |
82 | printError("Password Rejected") | |
83 | rednet.send(cli, "denied","response") | |
84 | end | |
85 | end | |
86 | - | print("Password: "..message) |
86 | + | --SSH |
87 | - | rednet.send(num, "confirm") |
87 | + | if protocol == "ssh" then |
88 | local result = shell.run(message) | |
89 | - | print("Password Denied") |
89 | + | rednet.send(client, result, "ssh") |
90 | - | rednet.send(num, "denied") |
90 | + | |
91 | log.close() | |
92 | end | |
93 | end | |
94 | ||
95 | --Start | |
96 | Init() | |
97 | print("Init Complete!") | |
98 | sleep(1) | |
99 | clear() | |
100 | UserData = load(".users") | |
101 | print("Loaded User Database!") | |
102 | sleep(1) | |
103 | PassData = load(".passwords") | |
104 | print("Loaded Password Database") | |
105 | sleep(1) | |
106 | clear() | |
107 | print("Hosting...") | |
108 | local UID = 1 | |
109 | sleep(1) | |
110 | clear() | |
111 | Host() | |
112 | ||
113 | --test | |
114 | --print("Test:") | |
115 | --print(UserData[2]) | |
116 | --print(PassData[2]) | |
117 | --sleep(1) | |
118 | - | --sleep(1) |
118 | + |