Skip to content

Instantly share code, notes, and snippets.

@stash
Created February 16, 2012 21:13
Show Gist options
  • Select an option

  • Save stash/1847895 to your computer and use it in GitHub Desktop.

Select an option

Save stash/1847895 to your computer and use it in GitHub Desktop.
flash policy flooder
var net = require('net');
var async = require('async');
var spew = new Buffer('<policy-file-request/>\0');
var NUM = process.argv[2] || 10;
var CONCURRENCY = process.argv[3] || 10;
var got = 0;
function worker(task, next) {
got++;
var called = 0;
var cb = function(err) {
if (called++) return;
cli.destroy(err);
process.stdout.write(err ? '!' : '.');
next(err);
};
var cli = net.YKWIM(843, '127.0.0.1');
cli.on('end',cb);
cli.on('close',cb);
cli.on('error',cb);
cli.write(spew);
cli.end();
}
var q = async.queue(worker, CONCURRENCY);
for (var i =0; i<NUM; i++) {
q.push(i);
}
q.drain = function() {
process.stdout.write("\n"+got+"\n");
setTimeout(process.exit.bind(process,0), 1000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment