Ranger15

sniffer

Apr 30th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. -- ComputerCraft Broadcast Rednet Monitor
  2. --   Monitor all traffic on local broadcast RedNet
  3. -- by Alexander "SquidLord" Williams (SaladinVrai)
  4.  
  5. -- Get the system label for identification
  6.  
  7. local SysName = os.getComputerLabel()
  8.  
  9. -- Iterate over all sides for rednet.open
  10.  
  11. for n,m in ipairs(rs.getSides()) do
  12.   rednet.open(m)
  13. end
  14.  
  15. -- Identify
  16.  
  17. print("SquidOS RedNet Sniffer ...")
  18. if SysName then
  19.   print("  Running on node: " .. os.getComputerLabel())
  20. else
  21.   write("  Running on ")
  22.   textutils.slowPrint("UNIDENTIFIED NODE")
  23. end
  24. -- This part was recoded by complover116 : )
  25. print()
  26. print("Press any key to stop")
  27. print()
  28.  
  29. -- Loop until any key is pressed
  30. -- This part was recoded by complover116 : )
  31. loop = true
  32. while loop == true do
  33.   Event, Id, Content = os.pullEvent()
  34.   if Event == "rednet_message" then
  35.     print(Id .. " (" .. textutils.formatTime(os.time(), false) ..")>")
  36.     print("  " .. Content)
  37.   elseif Event == "key" then
  38.    loop = false
  39.   end
  40. end
  41.  
  42. print("------------------------------")
  43. print("Listening stopped")
  44. print("Code by Squidlord")
  45. print("------------------------------")
  46. -- ShutDown the rednet
  47. for n,m in ipairs(rs.getSides()) do
  48.   rednet.close(m)
  49. end
Add Comment
Please, Sign In to add comment