Last active
August 29, 2015 14:06
-
-
Save xat/3ad9e6637944082b46ef to your computer and use it in GitHub Desktop.
simple flood script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var HOST = 'localhost'; | |
var PORT = 7777; | |
var WORKERS = 1; | |
var TIMEOUT = 30; // sec | |
var data = 'FLOODATTACK'; | |
var counter = 0; | |
var circulate = function(arr) { | |
var len = arr.length, pos = -1; | |
return !len ? void 0 : function() { | |
return arr[pos = ++pos % len]; | |
} | |
}; | |
var attack = function() { | |
var next = circulate(data.split('')); | |
var cli = net.connect(PORT, HOST, function() { | |
setInterval(function() { | |
cli.write(next()); | |
counter++; | |
}, 0); | |
}); | |
}; | |
for (var i = 0; i < WORKERS; i++) attack(); | |
setTimeout(function() { | |
console.log('wrote %s bytes within %s seconds', counter, TIMEOUT); | |
process.exit(); | |
}, TIMEOUT * 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment