Protótipo que procura uma rede / sub-rede por IPs que possuem uma porta específica aberta.
net = require 'net'
readline = require 'readline'
Socket = net.Socket
rl = readline.createInterface
input: process.stdin
output: process.stdout
class main
rl.question "PORT? ", (res) ->
PORT = res
rl.question "RANGE? ", (res) ->
LAN = res
rl.question "TIMEOUT? ", (res) ->
TIMEOUT= res
console.log "n*----- STARTING SCAN -----*n"
new portscan PORT, LAN, TIMEOUT
rl.close()
class portscan extends main
constructor:(port, host, timeout) ->
scan=(p, h, tt) ->
tcp = new Socket()
status = null
tcp.setTimeout tt
tcp.on "connect", ->
status = "open"
tcp.end()
tcp.on "timeout", -> tcp.destroy()
tcp.on "error", -> status = "closed"
tcp.on "close", -> console.log h if status is "open"
tcp.connect p, h
i = 1
while i <= 255
new scan port, host+ "." + i, timeout
i++