Coffeescript network scanner
Prototype that searches a network/subnet for a IPs that have a specific port open.
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++
Written by Austin Turnage
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#