forked from jamesryanbell/node-wraith
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
68 lines (56 loc) · 1.82 KB
/
index.js
File metadata and controls
68 lines (56 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
var fs = require('fs'),
wraith = require('./lib/wraith'),
spider = require('./lib/spider'),
chalk = require('chalk'),
path = require('path'),
rmdir = require('rimraf');
module.exports.run = run;
function run(configFile) {
var domains = [],
domainLabels = [],
outputFolder = '',
baseFolder = path.normalize(process.cwd() + '/'),
config = null;
try {
config = require(path.normalize(baseFolder + 'config/' + configFile + '.json'));
} catch(err) {
console.error(chalk.red('Configuration file specified could not be found or accessed'));
return false;
}
outputFolder = typeof config.outputDir === 'undefined' ? baseFolder + 'shots/' : baseFolder + 'shots/' + config.outputDir + '/';
outputFolder = path.normalize(outputFolder);
for(var domain in config.domains) {
domains.push(config.domains[domain].replace(/\/+$/, ''));
domainLabels.push(domain);
}
if( !config.fuzz ) {
config.fuzz = '20%';
}
if( !config.maxConnections ) {
config.maxConnections = 20;
}
if(config.snap) {
config.snap = path.normalize(baseFolder + config.snap);
} else {
config.snap = path.normalize(__dirname + '/snap.js');
}
var cb = function() {
var temp_path = path.normalize(__dirname + '/_temp');
//rmdir(temp_path + '/ff_profiles');
rmdir(temp_path, function(error){});
console.log('Done');
};
if( config.paths && config.paths.length > 0 ) {
wraith(config, config.engines, domains, config.sizes, domainLabels, outputFolder, cb);
} else if( config.spider ) {
config.spider = baseFolder + config.spider;
if (!fs.existsSync(config.spider)) {
spider(domains[0], config.spider, function() {
wraith(config, config.engines, domains, config.sizes, domainLabels, outputFolder, cb);
});
} else {
wraith(config, config.engines, domains, config.sizes, domainLabels, outputFolder, cb);
}
}
}