-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.html
171 lines (154 loc) · 6.03 KB
/
io.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>netkraken | single hive</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="css/hive.css" />
<link rel="stylesheet" type="text/css" href="css/inout.css" />
</head>
<body>
<ol class="breadcrumb">
<li><a href="/">netkraken</a></li>
<li>connections of <span class="selected"></span></li>
</ol>
<article>
<h1><img src="res/octopus.png">
connections of <span class="selected"></span>
</h1>
<div id="graph_0_0"></div>
<div id="infoText"> </div>
</article>
<script src="js/d3.min.js"></script>
<script src="js/link.js"></script>
<script src="js/hive.js"></script>
<script src="js/jsxcompressor.min.js"></script>
<script>
var source = getUrlVar("source");
source = (source === "") ? "model.live.reduced.json" : source;
console.log("source: " + source);
var selected = getUrlVar("selected");
selected = (selected === "") ? "foo" : selected;
console.log("selected: " + selected);
d3.selectAll(".selected").text(selected);
var blacklisted = getUrlVar("blacklisted");
blacklisted = (blacklisted === "") ? undefined : blacklisted;
console.log("blacklisted: " + blacklisted);
var name_regexp = getUrlVar("name-regexp");
console.log("name_regexp: " + name_regexp);
var size = getUrlVar("size");
console.log("size: " + size);
size = (size === "") ? 600 : size;
console.log("size: " + size);
var filename = source;
calcIndex = function(node) {
var sum = 0;
for (var i = 0; i < node.name.length; i++) {
sum += node.name.charCodeAt(i);
}
node.index = (131 * sum % 1000) / 1000.0;
node.scatterfactor = (77 * sum % 1000) / 1000 - .5;
}
var container = "#graph_0_0";
var info = "#infoText";
d3.xhr(source, function(response) {
var binary = JXG.decompress(response.response);
var data = JSON.parse(binary);
var links = [];
data.links.forEach(function(link) {
var sn = data.nodes[link.source];
var tn = data.nodes[link.target];
if (!startsWith(sn.name, selected) && !startsWith(tn.name, selected)) {
return;
}
if (blacklisted) {
if (startsWith(sn.name, blacklisted) || startsWith(tn.name, blacklisted)) {
return;
}
}
var sourceNode = {"name": sn.name};
var targetNode = {"name": tn.name};
if (startsWith(sourceNode.name, selected)) {
sourceNode.group = 1;
targetNode.group = 2;
}
if (startsWith(targetNode.name, selected)) {
sourceNode.group = 0;
targetNode.group = 1;
}
/*
if (name_regexp) {
var regexp = new RegExp(name_regexp);
var result = regexp.exec(sourceNode.name);
if (result) {
sourceNode.name = result[1];
}
result = regexp.exec(targetNode.name);
if (result) {
targetNode.name = result[1];
}
}
*/
sourceNode.id = sourceNode.name;
targetNode.id = targetNode.name;
sourceNode.hash = sourceNode.group + " " + sourceNode.id;
targetNode.hash = targetNode.group + " " + targetNode.id;
calcIndex(sourceNode);
calcIndex(targetNode);
var newLink = {"source": sourceNode, "target": targetNode, "protocol": link.protocol};
newLink.id = sourceNode.name + " -> " + targetNode.name;
//console.log(sourceNode.name + " -[" + link.protocol + "]-> " + targetNode.name);
links.push(newLink);
});
var nodesMap = {};
links.forEach(function(link){
nodesMap[link.source.hash] = link.source;
nodesMap[link.target.hash] = link.target;
});
var nodes = new Array();
for (var key in nodesMap) {
nodes.push(nodesMap[key]);
};
var nodeColorer = function(node) {return "grey";};
var linkColors = {
'socks': 'yellow',
'nfs': 'red',
'jdbc': 'orange',
'http': 'lightgreen',
'https': 'darkgreen',
'jms': 'cyan',
'tcp': 'tan',
'smtp': 'wheat',
'ftp': 'peru',
'unknown': 'black',
"ssh": "purple",
"cfinger": "lightgrey",
"ldap": "lightgrey",
"ldaps": "lightgrey",
"sd": "lightgrey",
};
var linkColorer = function(link) {
var color = linkColors[link.protocol];
return (color != undefined) ? color : "grey";
};
linkColorer.colorMap = linkColors;
renderInOut(
"",
window.location,
nodes,
links,
container,
info,
size,
nodeColorer,
linkColorer);
});
/*
http://localhost:5000/io.html?source=dummy2.json.gz.txt&selected=testing-4b42
http://localhost:5000/io.html?source=dummy2.json.gz.txt&selected=testing-179e
http://localhost:5000/io.html?source=dummy2.json.gz.txt&selected=testing-3064
*/
</script>
</body>
</html>