Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aabeling committed Aug 15, 2013
0 parents commit 31b730d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions README
@@ -0,0 +1 @@
jsportscanner.js taken from http://www.gnucitizen.org/static/blog/2006/08/jsportscanner.js
24 changes: 24 additions & 0 deletions index.html
@@ -0,0 +1,24 @@
<html>
<head>
<script src="jsportscanner.js" type="text/javascript"></script>
<script type="text/javascript">
<!--

function check() {
var host = document.getElementById('host').value;
var port = document.getElementById('port').value;
AttackAPI.PortScanner.scanTarget(function(target,port,result) {
alert(target + ":" + port + " " + result);
}, host, [port], 1000);
}
-->
</script>
</head>
<body>
<form>
Host: <input type="text" id="host" name="host" length="20" />
Port: <input type="text" id="port" name="port" length="6" />
<input type="submit" value="Check" onclick="check();return false" />
</body>

</html>
30 changes: 30 additions & 0 deletions 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);
};

0 comments on commit 31b730d

Please sign in to comment.