-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.html
109 lines (98 loc) · 3.58 KB
/
index.html
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
107
108
109
<html>
<head>
<meta charset="utf-8">
<title>Armadito</title>
<link rel="stylesheet" href="styles/main.css">
<script>
var token = null;
function register() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var obj = JSON.parse(xmlhttp.responseText);
token = obj.token;
console.log("token is now: " + token);
}
};
xmlhttp.open("GET", "/api/register", true);
xmlhttp.send(null);
}
function scan() {
console.log("scan");
var path_to_scan = document.getElementById("path").value;
console.log("path to scan: " + path_to_scan);
var data = {path: path_to_scan};
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "/api/scan", true);
xmlhttp.setRequestHeader("X-Armadito-Token", token);
xmlhttp.setRequestHeader("Content-TYpe", "application/json");
xmlhttp.send(JSON.stringify(data));
long_polling();
}
function long_polling() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var ev = JSON.parse(xmlhttp.responseText);
if (ev.event_type == "OnDemandProgressEvent") {
document.getElementById("progress").innerHTML = ev.progress;
document.getElementById("malware_count").innerHTML = ev.malware_count;
document.getElementById("suspicious_count").innerHTML = ev.suspicious_count;
document.getElementById("scanned_count").innerHTML = ev.scanned_count;
} else if (ev.event_type == "DetectionEvent") {
var results = document.getElementById("results")
var row = results.insertRow(1);
var path = row.insertCell(0);
path.innerHTML = ev.path;
var status = row.insertCell(1);
status.innerHTML = ev.scan_status;
var action = row.insertCell(2);
action.innerHTML = ev.scan_action;
var module = row.insertCell(3);
module.innerHTML = ev.module_name;
var module_report = row.insertCell(4);
module_report.innerHTML = ev.module_report;
}
long_polling(token);
}
};
console.log("sending request");
xmlhttp.open("GET", "/api/event", true);
xmlhttp.setRequestHeader("X-Armadito-Token", token);
xmlhttp.send(null);
}
function fun() {
console.log("submit");
}
</script>
</head>
<body>
<div id="banner">
<img src="images/armadito-64x64.png">
<span>Armadito</span>
</div>
<div>
Path: <input type="text" id="path"/><button onclick="scan()">Scan</button>
</div>
<div>
progress: <span id="progress">0</span>
</div>
<div>
malware_count: <span id="malware_count">0</span>
</div>
<div>
suspicious_count: <span id="suspicious_count">0</span>
</div>
<div>
scanned_count: <span id="scanned_count">0</span>
</div>
<div>
<table id="results" width="90%" border="1">
<tr> <th>path</th> <th>status</th> <th>action</th> <th>module</th> <th>report</th></tr>
</table>
</div>
<script>
register();
</script>
</body>
</html>