Guest User

Antivirus 1.0

a guest
Mar 4th, 2014
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. vr = "v1.0"
  2. viruses = {"Nubware", "Decay Virus", "Binary Virus", "Fry Virus", "Flamer"}
  3. infectedfiles = 0
  4. j = shell.getRunningProgram()
  5. while true do
  6. term.setBackgroundColor(colors.white)
  7. term.clear()
  8. term.setCursorPos(19, 1)
  9. term.setTextColor(colors.orange)
  10. term.write("ViProc")
  11. term.setCursorPos(10, 1)
  12. term.setBackgroundColor(colors.gray)
  13. for i = 1, 19 do
  14. x, y = term.getCursorPos()
  15. term.write(" ")
  16. y = y+1
  17. term.setCursorPos(x, y)
  18. end
  19. term.setCursorPos(34, 1)
  20. for i = 1, 19 do
  21. x, y = term.getCursorPos()
  22. term.write(" ")
  23. y = y+1
  24. term.setCursorPos(x, y)
  25. end
  26. term.setCursorPos(14, 4)
  27. term.setBackgroundColor(colors.red)
  28. term.write("                  ")
  29. term.setCursorPos(14, 7)
  30. term.write("                  ")
  31. term.setCursorPos(14, 10)
  32. term.write("                  ")
  33. term.setCursorPos(14, 13)
  34. term.write("                  ")
  35. term.setTextColor(colors.blue)
  36. term.setCursorPos(20, 4)
  37. term.write("Scan")
  38. term.setCursorPos(17, 7)
  39. term.write("Wipe Computer")
  40. term.setCursorPos(17, 10)
  41. term.write("Known Viruses")
  42. term.setCursorPos(17, 13)
  43. term.write("Control Panel")
  44. ev, button, posx, posy = os.pullEvent("mouse_click")
  45. if posx > 13 and posx < 29 and posy > 3 and posy < 5 then
  46.  term.clear()
  47.  term.setCursorPos(1,1)
  48. --Keywords to look for in files
  49. bad = {"function print", "hacked", "virus", "infected", "hacker", "keylog", "hack", "infect"}
  50. --DO NOT EDIT PAST THIS LINE
  51. gb = 1
  52. badfiles = {}
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. term.setTextColor(colors.lightBlue)
  56. term.write("ViProc "..vr)
  57. term.setCursorPos(1, 2)
  58. term.setTextColor(colors.yellow)
  59. --Make the dots move!
  60. for i = 1, 2 do
  61. term.write("Scanning for viruses.")
  62. sleep(0.5)
  63. term.clearLine()
  64. term.setCursorPos(1,2)
  65. term.write("Scanning for viruses..")
  66. sleep(0.5)
  67. term.clearLine()
  68. term.setCursorPos(1,2)
  69. term.write("Scanning for viruses...")
  70. sleep(0.5)
  71. term.clearLine()
  72. term.setCursorPos(1,2)
  73. end
  74. --Scan all files, looking for keywords
  75. s = fs.list("/")
  76. for _, v in pairs(s) do
  77.  if fs.isDir(v) == false then
  78.  h = fs.open(v, "r")
  79.  g = h.readAll()
  80.  h.close()
  81.  for i = 1, #bad do
  82.   --If it finds a keyword in the file and the file is not startup
  83.   if string.find(g, bad[i]) and v ~= j then
  84.    --Make sure it doesnt appear twice
  85.    for i = 1, #badfiles do
  86.     if v == badfiles[i] then
  87.      gb = 0
  88.     end
  89.    end
  90.   if gb == 1 then
  91.    table.insert(badfiles, v)
  92.    infectedfiles = infectedfiles+1
  93.   end
  94.   end
  95.  end
  96. end
  97. end
  98. term.setCursorPos(25, 1)
  99. term.setTextColor(colors.cyan)
  100. term.write("Number of infected files:")
  101. term.setTextColor(colors.orange)
  102. term.setCursorPos(25, 2)
  103. term.write(infectedfiles)
  104. sleep(2)
  105. if infectedfiles ~= 0 then
  106. term.setCursorPos(15, 4)
  107. print("Infected files:")
  108. term.setCursorPos(1, 5)
  109. textutild.pagesTabluate(badfiles)
  110. term.setCursorPos(1, 18)
  111. term.setTextColor(colors.orange)
  112. term.write("Press Y to delete these files or")
  113. term.setCursorPos(1, 19)
  114. term.write("press any other key to continue to the menu")
  115. ev, p1 = os.pullEvent("key")
  116. if p1 == keys.y then
  117.  for i = 1, #badfiles do
  118.   fs.delete(badfiles[i])
  119.  end
  120. term.setCursorPos(1, 2)
  121. term.setTextColor(colors.black)
  122. print("Files deleted")
  123. sleep(1)
  124. end
  125. else
  126. term.setTextColor(colors.orange)
  127. term.setCursorPos(1, 19)
  128. term.write("Press any key to continue")
  129. os.pullEvent("key")
  130. end
  131. elseif posx > 13 and posx < 29 and posy > 6 and posy < 8 then
  132.  term.clear()
  133.  term.setCursorPos(1,1)
  134.  term.setTextColor(colors.lightBlue)
  135.  term.write("ViProc "..vr)
  136.  term.setCursorPos(1, 2)
  137.  term.setTextColor(colors.blue)
  138.  print("Wiping computer...")
  139.  term.setBackgroundColor(colors.green)
  140.  term.setCursorPos(2, 9)
  141.  for i = 1, 40 do
  142.   term.write(" ")
  143.   sleep(0.1)
  144.  end
  145.  term.setBackgroundColor(colors.red)
  146.  term.setCursorPos(16, 10)
  147.  term.setTextColor(colors.orange)
  148.  term.write("Computer cleared.")
  149.  term.setCursorPos(1, 19)
  150.  term.setTextColor(colors.gray)
  151.  l = shell.programs()
  152.  s = fs.list("/")
  153.  for _, v in pairs(s) do
  154.   if v ~= j and fs.isDir(v) == false and fs.isReadOnly(v) == false then
  155.    fs.delete(v)
  156.   end
  157.  end
  158.  for _, v in pairs(l) do
  159.   if v ~= j then
  160.   fs.delete(v)
  161. end
  162. end
  163. term.setCursorPos(1, 19)
  164. term.write("Press any key to continue")
  165. os.pullEvent()
  166. elseif posx > 13 and posx < 29 and posy > 9 and posy < 11 then
  167.  term.clear()
  168.  term.setCursorPos(1,1)
  169.  term.setTextColor(colors.lightBlue)
  170.  term.write("ViProc "..vr)
  171.  term.setTextColor(colors.orange)
  172.  term.setCursorPos(19, 3)
  173.  term.write("Known Viruses:")
  174.  term.setCursorPos(1, 4)
  175.  textutils.pagedTabulate( viruses )
  176.  term.setCursorPos(1, 19)
  177.  term.setTextColor(colors.blue)
  178.  term.write("Press any key to continue")
  179.  os.pullEvent("key")
  180. elseif posx > 13 and posx < 29 and posy > 12 and posy < 14 then
  181.  while true do
  182.  term.setBackgroundColor(colors.blue)
  183.  term.clear()
  184.  term.setCursorPos(18,2)
  185.  term.setTextColor(colors.lightBlue)
  186.  term.write("Control Panel")
  187.  term.setTextColor(colors.yellow)
  188.  term.setCursorPos(15, 4)
  189.  term.setBackgroundColor(colors.cyan)
  190.  term.write("                  ")
  191.  term.setCursorPos(15, 7)
  192.  term.write("                  ")
  193.  term.setCursorPos(19, 4)
  194.  term.write("Edit files")
  195.  term.setCursorPos(20, 7)
  196.  term.write("Shell")
  197.  ev, button, x, y = os.pullEvent("mouse_click")
  198.   if x > 14 and x < 33 and y > 3 and y < 5 then
  199.    term.clear()
  200.    term.setCursorPos(2, 1)
  201.    term.setTextColor(colors.yellow)
  202.    term.write("Enter the file path:")
  203.    term.setCursorPos(2, 2)
  204.    term.setBackgroundColor(colors.blue)
  205.    term.write("                                    ")
  206.    term.setCursorPos(2,2)
  207.    term.setTextColor(colors.white)
  208.    local path = read()
  209.    shell.run("edit "..path)
  210.  elseif x > 14 and x < 33 and y > 6 and y < 8 then
  211.   term.setBackgroundColor(colors.black)
  212.   term.setTextColor(colors.yellow)
  213.   term.clear()
  214.   term.setCursorPos(1,1)
  215.   shell.run("rom/programs/shell")
  216. end
  217. end
  218. end
  219. end
Advertisement
Add Comment
Please, Sign In to add comment