Files
beef/modules/network/distributed_port_scanner/template.js
wade@bindshell.net 03ffb4703d Initial Import
git-svn-id: https://beef.googlecode.com/svn/trunk@2 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
2010-01-11 00:54:08 +00:00

46 lines
1.1 KiB
JavaScript

var AttackAPI = {
version: '0.1',
author: 'Petko Petkov (architect)',
homepage: 'http://www.gnucitizen.org'};
AttackAPI.PortScanner = {};
AttackAPI.PortScanner.scanPort = function (callback, target, port, timeout) {
var timeout = (timeout == null)?100:timeout;
var img = new Image();
img.onerror = function () {
if (!img) return;
img = undefined;
callback(target, port, 'open');
};
img.onload = img.onerror;
img.src = 'http://' + target + ':' + port;
setTimeout(function () {
if (!img) return;
img = undefined;
callback(target, port, 'closed');
}, timeout);
};
AttackAPI.PortScanner.scanTarget = function (callback, target, ports_str, timeout)
{
var ports = ports_str.split(",");
for (index = 0; index < ports.length; index++) {
AttackAPI.PortScanner.scanPort(callback, target, ports[index], timeout);
}
};
function do_main(){
var result = "";
var callback = function (target, port, status) {
result = target + ":" + port + " " + status;
return_result(result_id, result);
};
AttackAPI.PortScanner.scanTarget(callback, "TARGET", "PORTS", TIMEOUT);
}
do_main()