Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including netscan with all npm packages installed. Try it out:

var netscan = require("netscan")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

netscan v1.0.3

ip and port scanner

netscan

a pure javascript - ip and port scanner

npm version dependencies Build Status Pledge To Arupex! lifetimeDownloadCount

Install:

npm install netscan --save

Usage:

octets / ports / codes can be represented any number of ways

[{ min : 7, max : 8 },{ min : 9, max : 10 }]

{ min : 7, max : 10 }

[7, 8, 9, 10]

7

Code :

var scanner = new require('netscan')(); //may eventually take in options

// this would scan ip in the range of 192.168.1.[3-163]
// with ports of [80, 90, 443, 1337]
// and accept response codes of [200, 201, 202, 400, 401, 402, 403]

scanner.scan({

    protocol : ['http'],

    octet0: [192],
    octet1: [168],
    octet2: [1],
    octet3: [{min: 3, max: 163}], //range of 7 to 10 inclusive

    ports: [80, 90, 443, 1337],

    codes: [200, 201, 202, 400, 401, 402, 403], //only count it if a 200 comes back,

    errors : [], //like 'ETIMEDOUT'

    paths: '/' || [string], // optional to have it hit a specific endpoint

    headers: {}, // include the following headers in all request so you can do auth or something,

    timeout: 10000, //10 seconds timeout)

    ignoreResponse : true //tells it to not return the body as part of the results


}, function callback(results){

  /*
    results will contain response
    {
      uri : string,
      code : httpResponseCode ie. [200],
      body : httpResponseBody
    }

  */
});
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free