This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathindex.js
executable file
·106 lines (80 loc) · 3.38 KB
/
index.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// jshint esversion: 8
/**
* @file Collects evidence from websites on processed data in transit and at rest.
* @author Robert Riemann <robert.riemann@edps.europa.eu>
* @copyright European Data Protection Supervisor (2019)
* @license EUPL-1.2
*/
//const argv = require('./lib/argv');
const collector = require("./collector/index");
const inspector = require("./inspector/index");
const reporter = require("./reporter/index");
async function run(args, logger) {
// ########################################################
// create a new collection instance
// ########################################################
const collect = await collector(args, logger);
// create browser, session, har, pagesession etc to be able to collect
await collect.createSession();
//test the ssl and https connection
await collect.testConnection();
// go to the target url specified in the args - also possible to overload with a custom url.
await collect.getPage();
// ########################################################
// Collect Links, Forms and Cookies to populate the output
// ########################################################
await collect.collectLinks();
await collect.collectForms();
await collect.collectCookies();
await collect.collectLocalStorage();
await collect.collectWebsocketLog();
// browse sample history and log to localstorage
let browse_user_set = args.browseLink || [];
await collect.browseSamples(collect.output.localStorage, browse_user_set);
// END OF BROWSING - discard the browser and page
await collect.endSession();
// ########################################################
// inspecting - this will process the collected data and place it in a structured format in the output object
// ########################################################
const inspect = await inspector(
args,
logger,
collect.pageSession,
collect.output
);
await inspect.inspectCookies();
await inspect.inspectLocalStorage();
await inspect.inspectBeacons();
await inspect.inspectHosts();
// ########################################################
// Reporting - this will process the output object into different formats, yaml, json, html
// ########################################################
// args passed will determine what is stored on disk and what is sent to console
const report = reporter(args);
// args.output - determines if anything is stored on disk
// args.html - determines if html is sent to console
// args.json - determins if json is sent to console
// args.yaml - determins if yaml is sent to console
//websockets
report.saveJson(collect.output.websocketLog, "websockets-log.json", false);
// all
report.saveJson(collect.output, "inspection.json");
// cookies reporting
report.saveYaml(collect.output.cookies, "cookies.yml", false);
// local storage reporting
report.saveYaml(collect.output.localStorage, "local-storage.yml", false);
// beacons
report.saveYaml(collect.output.beacons, "beacons.yml", false);
// all
report.saveYaml(collect.output, "inspection.yml");
// store html on disk
report.generateHtml(collect.output);
// store docx on disk
await report.generateOfficeDoc(collect.output);
// convert html to pdf
await report.convertHtmlToPdf();
// store source on disk
report.saveSource(collect.source);
return collect.output;
}
module.exports = run;