Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modemSide = "right"
- modem = peripheral.wrap(modemSide)
- modem.open(512)
- msgTab = {}
- info = {"turtle",os.getComputerID(),gps.locate()}
- modem.transmit(65529,57,textutils.serialize(info))
- secretPass = "Ehfks87-i"
- secretPass2 = "sgxyg&%UI33%^&HS34DH-N"
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- clear()
- function makeString(l)
- if l < 1 then return nil end -- Check for l < 1
- local s = "" -- Start string
- for i = 1, l do
- s = s .. string.char(math.random(32, 126)) -- Generate random number from 32 to 126, turn it into character and add to string
- end
- return s -- Return string
- end
- function authentificationServer(port)
- authPass = false
- rndString = tostring(makeString(math.random(8,20)))
- modem.transmit(65529,port,textutils.serialize({"turtle",encrypt.encrypt(rndString,secretPass)}))
- qevent, qside, qch1, qch2, qmsg = os.pullEvent("modem_message")
- qmsgTab = textutils.unserialize(qmsg)
- if encrypt.decrypt(qmsgTab[2],secretPass2) == rndString then
- authPass = true
- end
- return authPass
- end
- function authentificationClient(port)
- qevent, qside, qch1, qch2, qmsg = os.pullEvent("modem_message")
- qmsgTab = textutils.unserialize(qmsg)
- print("msg")
- modem.transmit(65529,57,textutils.serialize({"turtle",encrypt.encrypt(encrypt.decrypt(qmsgTab[2],secretPass),secretPass2)}))
- end
- authentificationClient(57)
- clear()
- while true do
- event, side, ch1, ch2, msg = os.pullEvent("modem_message")
- msgTab = textutils.unserialize(msg)
- if msgTab[1] == "run" and msgTab[2] == os.getComputerID() then
- --if authentificationServer(57) == true then
- shell.run(msgTab[3])
- --end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement