@mi-sec/port-scanner

simple port scanner utility

Usage no npm install needed!

<script type="module">
  import miSecPortScanner from 'https://cdn.skypack.dev/@mi-sec/port-scanner';
</script>

README

@mi-sec/port-scanner

port scanner utility

  • Cross-platform - Support for:
    • CommonJS, ECMAScript Modules and UMD builds
    • Node >= 13.2.x (8, 10, 12 in progress)

port-scanner unit test port-scanner lint test

npm version lerna

Usage

*connectionOpts is a direct pass in to net.createConnection(<opts>)

import PortScanner from '@mi-sec/port-scanner';

const scan = new PortScanner( {
    host: '192.168.1.0/24',
    ports: [ 22 ],
    timeout: 1000,           // optional
    debug: false,            // optional
    onlyReportOpen: true,    // optional
    bannerGrab: true,        // optional
    identifyService: true,   // optional
    attemptToIdentify: true, // optional
    connectionOpts: {}       // optional*
} );

const data   = [];
let progress = 0;

result
    .on( 'ready', async () => {
        await result.scan();
    } )
    .on( 'data', ( d ) => {
        data.push( d );
    } )
    .on( 'progress', ( d ) => {
        console.log( 'progress', d );
    } )
    .on( 'done', ( d ) => {
        console.log( d );
    } );

Result:

[
  {
    host: '127.0.0.1',
    port: 22,
    status: 'open',
    banner: 'SSH-2.0-OpenSSH_7.9\r\n',
    time: 4.238488,
    service: 'ssh'
  }
]