Advertisement
Guest User

startup

a guest
Aug 19th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.98 KB | None | 0 0
  1. --Made by DEATHBYSH33P with bugfixing from 1lann
  2. os.loadAPI("specs")
  3. Enc = specs.Enc
  4. PC = specs.PasswordCracker
  5. shell.openTab("Red")
  6. local menu_options = { --This is our menu table. It contains basic data about the menu
  7.   [1] = {text="Log", color=colors.lime},
  8.   [2] = {text="Info", color=colors.lime},
  9.   [3] = {text="Hacked Ip's",color=colors.lime},
  10.   [4] = {text="Scanned Ip's",color=colors.lime},
  11.   [5] = {text="Scan for Devices",color=colors.lime},
  12.   [6] = {text="Hack an IP",color=colors.lime},
  13.   [7] = {text="Connect",color=colors.lime}
  14. }
  15. local termX, termY = term.getSize() --The x/y size of the terminal
  16. local function menuDraw(selected) --Our main draw function
  17.   local yPos = termY/2 - #menu_options/2 --The initial y position
  18.   for index, data in pairs(menu_options) do
  19.     menu_options[index].bounds = { --Create a new table in each option with the boundary data
  20.       x1 = termX/2 - (#data.text+4)/2;
  21.       x2 = termX/2 + (#data.text+4)/2;
  22.       y = yPos;
  23.     }
  24.     term.setTextColor(data.color)
  25.     term.setCursorPos(data.bounds.x1, data.bounds.y)
  26.  
  27.     local text =
  28.       index==selected and "[ "..data.text.." ]" or
  29.       "  "..data.text.."  " --Essentially an if statement, but in a contracted form
  30.     term.write(text)
  31.     yPos = yPos+1 --Increment the initial y pos so we can move on the next line
  32.   end
  33. end
  34.  
  35. local function checkClick(x,y) --Check the mouse click to see if there's a menu option
  36.   for index, data in pairs(menu_options) do
  37.     if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
  38.       return index --Returns the index of the clicked option
  39.     end
  40.   end
  41.   return false --If it went through the entire for loop without success, return false
  42. end
  43.  
  44. term.setBackgroundColor(colors.white)
  45. term.clear()
  46.  
  47. local selector = 1 --Our selector
  48. while true do --The main loop. I would generally put this inside of a function for a program.
  49.   menuDraw(selector) --Draw the menu first
  50.   local e = {os.pullEvent()} --Pull an event and put the returned values into a table
  51.   if e[1] == "key" then --If it's a key...
  52.     if e[2] == keys.down then -- ... and it's the down arrow
  53.       selector = selector < #menu_options and selector+1 or 1 --Increment the selector if the selector < #menu_options. Otherwise reset it to 1
  54.     elseif e[2] == keys.up then
  55.       selector = selector > 1 and selector-1 or #menu_options --Decrement the selector if the selector > 1. Otherwise, reset it to #menu_options
  56.     elseif e[2] == keys.enter then
  57.       break --Break out of the loop
  58.     end
  59.   elseif e[1] == "mouse_click" then
  60.     local value = checkClick(e[3], e[4]) --Check the mouse click
  61.     if value then --If checkClick returns a value and not false
  62.       selector = value --Set the selector to that value and break out of the loop
  63.       break
  64.     end
  65.   end
  66. end
  67.  
  68. term.clear()
  69. term.setCursorPos(1,1)
  70. if selector == (1) then
  71. local file = fs.open("log","r")
  72. read = file.readAll()
  73. print(read)
  74. file.close()
  75. print("Press any key to Continue")
  76. io.read()
  77. os.reboot()
  78. elseif selector == (2) then
  79. local file = fs.open("specs","r")
  80. read = file.readAll()
  81. print(read)
  82. print("Press any key to Continue")
  83. io.read()
  84. os.reboot()
  85. elseif selector == (3) then
  86. local file = fs.open("contacts","r")
  87. read = file.readAll()
  88. print(read)
  89. print("Press any Key to Continue")
  90. io.read()
  91. os.reboot()
  92. elseif selector == (4) then
  93. local file = fs.open("scanned","r")
  94. read = file.readAll()
  95. print(read)
  96. file.close()
  97. print("Press any key to Continue")
  98. io.read()
  99. os.reboot()
  100. elseif selector == (5) then
  101. rednet.broadcast("Scan")
  102. id,msg = rednet.receive()
  103. print("ID Found!")
  104. sleep(1)
  105. local file = fs.open("scanned","a")
  106. file.writeLine(id)
  107. file.close()
  108. os.reboot()
  109. elseif selector == (6) then
  110. print("Enter the ID")
  111. Hack = read()
  112. print("Attempting to Crack ID's Password with")
  113. print("PasswordCracker lvl "..PC)
  114. rednet.send(tonumber(Hack),"PC",tonumber(PC))
  115. id,msg,msg2 = rednet.receive(5)
  116. if msg2 == ("success") then
  117. print(msg)
  118. local file = fs.open("contacts","a")
  119. file.writeLine(tonumber(Hack).." : "..tostring(msg))
  120. file.close()
  121. sleep(1)
  122. os.reboot()
  123. elseif msg2 == ("fail") then
  124. print(msg)
  125. sleep(1)
  126. os.reboot()
  127. elseif not id then
  128. print("No Response!")
  129. sleep(1)
  130. os.reboot()
  131. end
  132. elseif selector == (7) then
  133.   print("Type in the id and password!")
  134.   print("ID : ")
  135.   term.setCursorPos(6,2)
  136.   Hack = io.read()
  137.   print("PassWord : ")
  138.   term.setCursorPos(12,3)
  139.   Hack2 = io.read()
  140.   print("Connecting...")
  141.   rednet.send(tonumber(Hack),"Connect",tonumber(Hack2))
  142.   id,msg = rednet.receive(5)
  143.   if id then
  144.   if msg == ("success") then
  145.     textutils.slowPrint("Access Granted!")
  146.     term.clear()
  147.     term.setCursorPos(1,1)
  148.     end
  149.     elseif not id then
  150.     print("No Response!")
  151.     sleep(1)
  152.     os.reboot()
  153.      end
  154.     function logged()
  155.         local menu_options = { --This is our menu table. It contains basic data about the menu
  156.           [1] = {text="Check and edit Log!", color=colors.blue},
  157.           [2] = {text="Check Files!", color=colors.orange},
  158.           [3] = {text="Disconnect!", color=colors.cyan}
  159.         }
  160.         local termX, termY = term.getSize() --The x/y size of the terminal
  161.         local function menuDraw(selected) --Our main draw function
  162.           local yPos = termY/2 - #menu_options/2 --The initial y position
  163.           for index, data in pairs(menu_options) do
  164.             menu_options[index].bounds = { --Create a new table in each option with the boundary data
  165.               x1 = termX/2 - (#data.text+4)/2;
  166.               x2 = termX/2 + (#data.text+4)/2;
  167.               y = yPos;
  168.             }
  169.             term.setTextColor(data.color)
  170.             term.setCursorPos(data.bounds.x1, data.bounds.y)
  171.  
  172.             local text =
  173.               index==selected and "[ "..data.text.." ]" or
  174.               "  "..data.text.."  " --Essentially an if statement, but in a contracted form
  175.             term.write(text)
  176.             yPos = yPos+1 --Increment the initial y pos so we can move on the next line
  177.         end
  178.       end
  179.  
  180.     local function checkClick(x,y) --Check the mouse click to see if there's a menu option
  181.       for index, data in pairs(menu_options) do
  182.         if x>= data.bounds.x1 and x<= data.bounds.x2 and y==data.bounds.y then
  183.           return index --Returns the index of the clicked option
  184.         end
  185.       end
  186.       return false --If it went through the entire for loop without success, return false
  187.     end
  188.  
  189.     term.setBackgroundColor(colors.white)
  190.     term.clear()
  191.  
  192.     local selector = 1 --Our selector
  193. while true do --The main loop. I would generally put this inside of a function for a program.
  194.   menuDraw(selector) --Draw the menu first
  195.   local e = {os.pullEvent()} --Pull an event and put the returned values into a table
  196.   if e[1] == "key" then --If it's a key...
  197.     if e[2] == keys.down then -- ... and it's the down arrow
  198.       selector = selector < #menu_options and selector+1 or 1 --Increment the selector if the selector < #menu_options. Otherwise reset it to 1
  199.     elseif e[2] == keys.up then
  200.       selector = selector > 1 and selector-1 or #menu_options --Decrement the selector if the selector > 1. Otherwise, reset it to #menu_options
  201.     elseif e[2] == keys.enter then
  202.       break --Break out of the loop
  203.     end
  204.   elseif e[1] == "mouse_click" then
  205.     local value = checkClick(e[3], e[4]) --Check the mouse click
  206.     if value then --If checkClick returns a value and not false
  207.       selector = value --Set the selector to that value and break out of the loop
  208.       break
  209.     end
  210.   end
  211. end
  212.  
  213. term.clear()
  214. term.setCursorPos(1,1)
  215. if selector == (1) then
  216. print("Not Available!")
  217. sleep(1)
  218. logged()
  219. elseif selector == (2) then
  220. rednet.send(tonumber(Hack),"files")
  221. id,msg = rednet.receive()
  222. print(msg)
  223. print("Press any key to Continue!")
  224. io.read()
  225. logged()
  226. elseif selector == (3) then
  227. print("Disconnecting..")
  228. sleep(1)
  229. os.reboot()
  230. end
  231. end
  232. logged()
  233. elseif msg == ("fail") then
  234. textutils.slowPrint("ID or PassWord did not match!")
  235. elseif not id then
  236. print("No response")
  237. sleep(1)
  238. os.reboot()
  239. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement