From 31b730d442c6c3e3c820e25a66e427b8ca095c15 Mon Sep 17 00:00:00 2001 From: aabeling Date: Thu, 15 Aug 2013 10:11:36 +0200 Subject: [PATCH] initial commit --- README | 1 + index.html | 24 ++++++++++++++++++++++++ jsportscanner.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 README create mode 100644 index.html create mode 100644 jsportscanner.js diff --git a/README b/README new file mode 100644 index 0000000..0c6c8c7 --- /dev/null +++ b/README @@ -0,0 +1 @@ +jsportscanner.js taken from http://www.gnucitizen.org/static/blog/2006/08/jsportscanner.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..75d42aa --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + + +
+ Host: + Port: + + + + diff --git a/jsportscanner.js b/jsportscanner.js new file mode 100644 index 0000000..73d2378 --- /dev/null +++ b/jsportscanner.js @@ -0,0 +1,30 @@ +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, timeout) +{ + for (index = 0; index < ports.length; index++) + AttackAPI.PortScanner.scanPort(callback, target, ports[index], timeout); +};