Advertisement
LazerAio

Telnet.lua

Feb 24th, 2022
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. --setup
  2. os.pullEvent = os.pullEventRaw
  3. local function drawTaskBar(s,x)
  4. term.setCursorPos(x,18)
  5. term.setBackgroundColor( colors.black )
  6. term.clearLine()
  7. term.write(s)
  8. term.setBackgroundColor( colors.gray )
  9. term.setCursorPos(1,1)
  10. end
  11. term.setBackgroundColor( colors.gray )
  12. term.clear()
  13. drawTaskBar("Telnet.lua", 1)
  14. --Menu
  15. local function centerCursor(s, yo)
  16. local width = ({term.getSize()})[1]
  17. local height = ({term.getSize()})[2]
  18. term.setCursorPos(((width/2)-s),(height/2)+yo)
  19. end
  20. local function communicate(side, target)
  21. modem = peripheral.wrap(side)
  22. rednet.open(side)
  23. textutils.slowPrint("Connecting!")
  24. term.clear()
  25. centerCursor(string.len("Incoming Telnet Request"), -5)
  26. rednet.send(tonumber(target) ,"Incoming Telnet Request")
  27. print("OK")
  28. while true do
  29. print(target..":")
  30. command = read()
  31. rednet.send(tonumber(target), command)
  32. RXID, RX = rednet.receive()
  33. print("////")
  34. print(RXID..":")
  35. print(RX)
  36. end
  37. end
  38. local function menu()
  39. while true do
  40. centerCursor(string.len("Welcome"), -2)
  41. print("Welcome")
  42. centerCursor(string.len("Target adress"), -1)
  43. print("Target adress")
  44. centerCursor(string.len("****"), 0)
  45. Target = read()
  46. centerCursor(string.len("Computer ID is: xxxx"), 1)
  47. shell.run("id")
  48. centerCursor(string.len("Side:"), 2)
  49. print("Side: ")
  50. centerCursor(string.len("XXXX"), 3)
  51. side = read()
  52. sleep(1)
  53. term.clear()
  54. centerCursor(string.len("Press 'enter' when ready"), 0)
  55. print("Press 'enter' when ready")
  56. read()
  57. communicate(side, Target)
  58. end
  59. end
  60. --INIT
  61. menu()
  62. return "OK"
  63. --os.reboot()
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement