Skip to content

Commit

Permalink
v0.4.16: Version bump & move to a stream object with .spawn()
Browse files Browse the repository at this point in the history
  • Loading branch information
jas- committed Oct 21, 2018
1 parent 49b7223 commit c235b24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions lib/classes/tools.js
Expand Up @@ -9,7 +9,7 @@
const async = require('async');
const merge = require('deepmerge');
const caller = require('stack-trace');
const proc = require('child_process').exec;
const proc = require('child_process').spawn;
const emitter = require('events').EventEmitter;

const network = require('./networking.js');
Expand Down Expand Up @@ -74,7 +74,8 @@ class tools extends emitter {

if (Array.isArray(value)) {
return this.flatten(value, obj);
} else {
}
else {
result.push(value);
}
}
Expand Down Expand Up @@ -102,28 +103,39 @@ class tools extends emitter {

Object.keys(opts.range).forEach(function blocks(block) {

// Acquire an array of ranges
const range = opts.range[block];

// Create a new function for each range block
funcs[range] = function block(callback) {
const report = [];


// Capture the flags, & ranges as a command string
cmd = scope.command(opts, range);

// Split up cmd for .spawn()
const obj = cmd.split(" ");
cmd = obj[0];
const args = obj.slice(1);

if (opts.verbose)
console.log(`Running: ${cmd}`);

const report = [];

const execute = proc(cmd, (err, stdout, stderr) => {
if (err)
return reporting.reports(opts, err, callback);
});
// Push it on to the heap
const execute = proc(cmd, args);

// Discard stderr for now, maybe log?
execute.stderr.on('data', (chunk) => {
/* Silently discard stderr messages to not interupt scans */
});

// Push to array of reports
execute.stdout.on('data', (chunk) => {
report.push(chunk);
});

// Push report array to reporting function on stream end
execute.stdout.on('end', () => {
if (report.length > 0)
return reporting.reports(opts, report, callback);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "libnmap",
"version": "v0.4.15",
"version": "v0.4.16",
"description": "libnmap for node.js",
"author": "Jason Gerfen <jason.gerfen@gmail.com>",
"keywords": [
Expand Down

0 comments on commit c235b24

Please sign in to comment.