|
|
@ -1,6 +1,8 @@
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
var request = require('request');
|
|
|
|
var request = require('request');
|
|
|
|
var fs = require("fs");
|
|
|
|
var fs = require('fs');
|
|
|
|
var path =require("path");
|
|
|
|
var path = require('path');
|
|
|
|
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
//TODO
|
|
|
|
exports.detectFromHTML = function(options) {};
|
|
|
|
exports.detectFromHTML = function(options) {};
|
|
|
@ -10,19 +12,19 @@ exports.detectFromUrl = function (options,cb) {
|
|
|
|
var url = options.url;
|
|
|
|
var url = options.url;
|
|
|
|
|
|
|
|
|
|
|
|
if (options.debug) {
|
|
|
|
if (options.debug) {
|
|
|
|
console.log("Fetching the page");
|
|
|
|
console.log('Fetching the page');
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getHTMLFromUrl(url, function(err, data) {
|
|
|
|
getHTMLFromUrl(url, function(err, data) {
|
|
|
|
if (err) {
|
|
|
|
if (err || data === null) {
|
|
|
|
cb(err,null)
|
|
|
|
cb(err, null);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
runWrappalyer(options, data, function(err, detected, appInfo) {
|
|
|
|
runWrappalyer(options, data, function(err, detected, appInfo) {
|
|
|
|
cb(null,detected,appInfo)
|
|
|
|
cb(null, detected, appInfo);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function getHTMLFromUrl(url, cb) {
|
|
|
|
function getHTMLFromUrl(url, cb) {
|
|
|
|
request(url, function(error, response, body) {
|
|
|
|
request(url, function(error, response, body) {
|
|
|
@ -34,7 +36,7 @@ function getHTMLFromUrl (url,cb) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
cb(null, data);
|
|
|
|
cb(null, data);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
cb(error,null)
|
|
|
|
cb(error, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -42,21 +44,21 @@ function getHTMLFromUrl (url,cb) {
|
|
|
|
function getAppsJson(cb) {
|
|
|
|
function getAppsJson(cb) {
|
|
|
|
fs.readFile(path.resolve(__dirname, 'apps.json'), 'utf8', function(err, data) {
|
|
|
|
fs.readFile(path.resolve(__dirname, 'apps.json'), 'utf8', function(err, data) {
|
|
|
|
if (err) throw err;
|
|
|
|
if (err) throw err;
|
|
|
|
return cb(null, JSON.parse(data))
|
|
|
|
return cb(null, JSON.parse(data));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function runWrappalyer(options, data, cb) {
|
|
|
|
function runWrappalyer(options, data, cb) {
|
|
|
|
var debug = options.debug || false;
|
|
|
|
var debug = options.debug || false;
|
|
|
|
|
|
|
|
|
|
|
|
var wappalyzer = require("./wappalyzer").wappalyzer;
|
|
|
|
var wappalyzer = require('./wappalyzer').wappalyzer;
|
|
|
|
getAppsJson(function(err, apps) {
|
|
|
|
getAppsJson(function(err, apps) {
|
|
|
|
var w = wappalyzer;
|
|
|
|
var w = wappalyzer;
|
|
|
|
w.driver = {
|
|
|
|
w.driver = {
|
|
|
|
log: function(args) {
|
|
|
|
log: function(args) {
|
|
|
|
if (debug) {
|
|
|
|
if (debug) {
|
|
|
|
console.log(args.message);
|
|
|
|
console.log(args.message);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
init: function() {
|
|
|
@ -72,12 +74,13 @@ function runWrappalyer(options,data,cb) {
|
|
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
if (debug) {
|
|
|
|
console.log(app);
|
|
|
|
console.log(app);
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
cb(null,detectedApps,w.detected[url])
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cb(null, detectedApps, w.detected[url]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
w.init();
|
|
|
|
w.init();
|
|
|
|
w.analyze(options.hostname,options.url, data)
|
|
|
|
w.detected = [];
|
|
|
|
|
|
|
|
w.analyze(options.hostname, options.url, data);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|