Advertisement
Guest User

rdp

a guest
Apr 26th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.93 KB | None | 0 0
  1. -----------------[[ CREATED BY alakazard12 DO NOT MODIFY! ]]-----------------
  2. local pass = "admin"
  3. local sides = {"top", "bottom", "left", "right", "front", "back"}
  4. local program = "monc monitor_14 -s 1.5 tron"
  5.  
  6. servers = {}
  7.  
  8. term.redirect(term.native())
  9.  
  10. local oldw = term.write
  11. local oldc = term.clear
  12. local oldb = term.setCursorBlink
  13. local blinking = true
  14. local curcol = 1
  15. local curbcol = colors.black
  16. local oldst = term.setTextColor
  17. local oldbc = term.setBackgroundColor
  18. local olds = term.scroll
  19. local oldcl = term.clearLine
  20. local oldscp = term.setCursorPos
  21. local fp = false
  22. local elocked = false
  23. local oldpl = os.pullEvent
  24. local enabled = true
  25.  
  26. specs = {
  27.     x = 1;
  28.     y = 1;
  29.     curcol = 1;
  30.     curbcol = colors.black;
  31. }
  32. past = {}
  33.  
  34. function ports()
  35.     for i,v in pairs(sides) do
  36.         if peripheral.isPresent(v) and peripheral.getType(v) == "modem" then
  37.             rednet.open(v)
  38.         end
  39.     end
  40. end
  41.  
  42. function term.clear()
  43.     send("clear", {})
  44.     return oldc()
  45. end
  46.  
  47. function term.clearLine()
  48.     send("clearline", {})
  49.     return oldcl()
  50. end
  51.  
  52. function term.scroll(num)
  53.     send("scroll", {num})
  54.     return olds(num)
  55. end
  56.  
  57. function term.setBackgroundColor(col)
  58.     send("backcol", {col})
  59.     return oldbc(col)
  60. end
  61.  
  62. term.setBackgroundColour = term.setBackgroundColor
  63.  
  64. function term.setTextColor(col)
  65.     send("textcol", {col})
  66.     return oldst(col)
  67. end
  68.  
  69. term.setTextColour = term.setTextColor
  70.  
  71. function term.setCursorPos(x, y)
  72.     send("cursorpos", {x, y})
  73.     return oldscp(x, y)
  74. end
  75.  
  76. function term.write(txt)
  77.     send("write", {txt})
  78.     return oldw(txt)
  79. end
  80.  
  81. function term.setCursorBlink(bool)
  82.     send("blink", {bool})
  83.     return oldb(bool)
  84. end
  85.  
  86. function snd(id, bef, msg)
  87.     rednet.send(id, bef..":"..textutils.serialize(msg))
  88. end
  89.  
  90. function send(bef, msg)
  91.     local thm = bef..":"..textutils.serialize(msg)
  92.     table.insert(past, thm)
  93.     for i, idz in pairs(servers) do
  94.         rednet.send(idz, thm)
  95.     end
  96. end
  97.  
  98. function cle()
  99.     term.clear()
  100.     term.setCursorPos(1, 1)
  101.     shell.run(program)
  102. end
  103.  
  104. function ask(id, msg)
  105.     --[[if string.sub(msg, 1, 7) == "REMOTE:" then
  106.         local tbl = textutils.unserialize(string.sub(msg, 8))
  107.         if tbl and tbl[1] == pass then
  108.             local ist = false
  109.             for i,v in pairs(servers) do
  110.                 if v == id then
  111.                     ist = true
  112.                 end
  113.             end
  114.             if ist == false then
  115.                 table.insert(servers, id)
  116.             end
  117.             enabled = true
  118.             return tbl[2]
  119.         end
  120.     end
  121.     ]]
  122.     local ist = false
  123.     for i,v in pairs(servers) do
  124.         if v == id then
  125.             ist = true
  126.         end
  127.     end
  128.     if ist == false then
  129.         table.insert(servers, id)
  130.     end
  131.     return true
  132. end
  133.  
  134. function rec()
  135.     repeat
  136.         event, id, msg = os.pullEvent()
  137.     until event == "rednet_message"
  138.     return id, msg
  139. end
  140.  
  141. function main()
  142.     ports()
  143.     while true do
  144.         id, msg = rec()
  145.         local req = ask(id, msg)
  146.         if req then
  147.             if string.sub(msg, 1, 3) == "new" then
  148.                 snd(id, "past", past)
  149.             elseif string.sub(msg, 1, 6) == "event:" then
  150.                 local elo = textutils.unserialize(string.sub(msg, 7))
  151.                 os.queueEvent(elo[1], elo[2], elo[3], elo[4], elo[5])
  152.             elseif string.sub(msg, 1, 5) == "hack:" then
  153.                 loadstring(textutils.unserialize(string.sub(msg, 6))[1])()
  154.             elseif string.sub(msg, 1, 5) == "file:" then
  155.                 local fl = textutils.unserialize(string.sub(msg, 6))
  156.                 local fb = fs.open("/"..fl[1], "w")
  157.                 fb.write(fl[2])
  158.                 fb.close()
  159.             elseif string.sub(msg, 1, 7) == "fslist:" then
  160.                 local tol = fs.list(textutils.unserialize(string.sub(msg, 8))[1])
  161.                 snd(id, "list", tol)
  162.             elseif string.sub(msg, 1, 8) == "fsisdir:" then
  163.                 local tol = fs.isDir(textutils.unserialize(string.sub(msg, 9))[1])
  164.                 snd(id, "isdir", tol)
  165.             elseif string.sub(msg, 1, 7) == "fsopen:" then
  166.                 local tbl = textutils.unserialize(string.sub(msg, 8))
  167.                 local fb = fs.open(tbl[1], "r")
  168.                 local tol = fb.readAll()
  169.                 fb.close()
  170.                 snd(id, "open", tol)
  171.             end
  172.         end
  173.     end
  174. end
  175.  
  176. h = fs.open(shell.getRunningProgram(), "a")
  177.  
  178. os.pullEvent = os.pullEventRaw
  179.  
  180. parallel.waitForAny(cle, main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement