2018-08-05 05:48:31 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var basedir = path.join(__dirname, 'emails');
|
|
|
|
var files = fs.readdirSync(basedir)
|
|
|
|
|
|
|
|
var emails = {};
|
|
|
|
files.forEach(function (fname) {
|
|
|
|
var fpath = path.join(basedir, fname);
|
|
|
|
var data;
|
|
|
|
var email;
|
|
|
|
var iat;
|
2018-08-05 07:20:06 +00:00
|
|
|
var mdata;
|
2018-08-05 05:48:31 +00:00
|
|
|
if (!/\.data$/.test(fname)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
data = JSON.parse(fs.readFileSync(fpath));
|
|
|
|
email = fname.replace('\.' + data.domains.join('') + '\.data', '');
|
2018-08-05 07:20:06 +00:00
|
|
|
mdata = JSON.parse(fs.readFileSync(path.join(basedir, email)));
|
2018-08-05 05:48:31 +00:00
|
|
|
if (data.iat) {
|
|
|
|
iat = new Date(data.iat).toISOString();
|
|
|
|
}
|
|
|
|
if (!emails[email]) {
|
|
|
|
emails[email] = {
|
|
|
|
domains: []
|
|
|
|
, ports: []
|
2018-08-05 07:20:06 +00:00
|
|
|
, nodes: [ { createdAt: iat, scheme: 'mailto', type: 'email', name: email } ]
|
2018-08-05 05:48:31 +00:00
|
|
|
, jtis: []
|
|
|
|
};
|
|
|
|
}
|
|
|
|
emails[email].jtis.push(data.id);
|
|
|
|
data.domains.forEach(function (d) {
|
2018-08-05 07:20:06 +00:00
|
|
|
emails[email].domains.push({ createdAt: iat, name: d, wildcard: true, hostname: mdata.hostname
|
|
|
|
, os: mdata.os_type, arch: mdata.os_arch });
|
2018-08-05 05:48:31 +00:00
|
|
|
});
|
|
|
|
data.ports.forEach(function (p) {
|
2018-08-05 07:20:06 +00:00
|
|
|
emails[email].ports.push({ createdAt: iat, number: p, hostname: mdata.hostname
|
|
|
|
, os: mdata.os_type, arch: mdata.os_arch });
|
2018-08-05 05:48:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log('[\n' + Object.keys(emails).map(function (k) { return JSON.stringify(emails[k]); }).join(',\n') + '\n]');
|