-
-
Save suissa/3274956 to your computer and use it in GitHub Desktop.
A port scan with node.js ( by Hacksparrow <http://www.hacksparrow.com> )
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
#!/usr/bin/env node | |
var net = require('net'), | |
host = 'localhost', | |
start = 1, | |
end = 10000, | |
timeout = 15000; | |
while ( start <= end ) { | |
var port = start; | |
(function ( port ) { | |
var s = new net.Socket(); | |
s.setTimeout( timeout, function () { | |
s.destroy(); | |
}); | |
s.connect( port, host, function () { | |
console.log( 'OPEN: ' + port ); | |
}); | |
s.on( 'data', function ( data ) { | |
console.log( port + ': ' + data ); | |
s.destroy(); | |
}); | |
s.on( 'error', function () { | |
s.destroy(); | |
}); | |
} ( port )); | |
start++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment