-
Notifications
You must be signed in to change notification settings - Fork 234
/
index.html
539 lines (455 loc) · 18.9 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
body {
margin: 0;
padding: 0;
background: black;
}
#titlediv {
font-family: monospace;
text-align: center;
font-size:48px;
position:fixed;
width:100%;
height:50px;
color:white;
background-color:black;
padding:5px;
top:0px;
overflow-y: auto;
}
#attackdiv {
font-family: monospace;
font-size:10px;
position:fixed;
width:50%;
height:100px;
color:white;
background-color:black;
padding:5px;
bottom:0px;
overflow-y: auto;
}
#container1 {
position: relative;
width: 100vw;
height: 100vh;
max-width:100%;
max-height:100%
}
#about {
display: hidden;
}
#aboutdiv {
text-align:right;
width:100px;
height:100px;
top:0px;
right:0px;
position:fixed;
padding:10px;
color: white;
}
#ccdiv {
text-align:right;
width:100px;
height:20px;
bottom:0px;
right:0px;
position:fixed;
padding:5px;
color: white;
}
#about {display:none;}
/* Overlay */
#simplemodal-overlay {background-color:#000;}
/* Container */
#simplemodal-container {height:460px; width:600px; color:#bbb; background-color:#333; border:4px solid #444; padding:12px;}
#simplemodal-container .simplemodal-data {padding:8px;}
#simplemodal-container code {background:#141414; border-left:3px solid #65B43D; color:#bbb; display:block; font-size:12px; margin-bottom:12px; padding:4px 6px 6px;}
#simplemodal-container a {color:#ddd;}
#simplemodal-container a.modalCloseImg {background:url(../img/basic/x.png) no-repeat; width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-15px; right:-16px; cursor:pointer;}
#simplemodal-container h3 {color:#84b8d9;}
#simplemodal-container a.modalCloseImg {
background:url(x.png) no-repeat; /* adjust url as required */
width:25px;
height:29px;
display:inline;
z-index:3200;
position:absolute;
top:-15px;
right:-18px;
cursor:pointer;
}
</style>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://d3js.org/d3.geo.projection.v0.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<script src="https://datamaps.github.io/scripts/datamaps.world.min.js?v=1"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="jquery.simplemodal-1.4.4.js"></script>
<script>
function about() {
$("#about").modal();
}
</script>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<audio id="starwars" src="Blaster-Solo.wav" preload="auto"></audio>
<audio id="tng" src="tng_torpedo_clean.mp3" preload="auto"></audio>
<audio id="b5" src="B5-interceptor1.wav" preload="auto"></audio>
<audio id="wargames" src="WarGames-KeyPress.wav" preload="auto"></audio>
<audio id="pew" src="pew.mp3" preload="auto"></audio>
<audio id="galaga" src="shot_sound.mp3" preload="auto"></audio>
<audio id="asteroids" src="asteroids.mp3" preload="auto"></audio>
<audio id="china" src="china.mp3" preload="auto"></audio>
<audio id="timallen" src="timallen.wav" preload="auto"></audio>
<center><div id="container1"></div></center>
<div id="titlediv">IPew Attack Map</div>
<div id="attackdiv"></div>
<div id="aboutdiv"><i class="fa fa-question-circle fa-2x" onClick="about();"></i></div>
<div id="ccdiv">
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a>
</div>
<div id="about">
<h3>About IPew</h3>
Attack maps are the <span style="font-family: monospace;"><blink></span> tag of information security. They are pure eye candy, meant to scare the general public and <i>WOW</i> unsuspecting executives visiting Security Operations Centers. Yet, security vendors keep cranking them out. We didn't want organizations without "real" data or l33t animation skills to to feel left out, so we built this map for anyone to use [CC BY-SA]. Plus, they're all missing sound effects! And, most (all, really) use mind-numbingly dumb map projections, begging the question: <i>"Does Greenland make my map look big?"</i>.<br/>
<br/>
The default map uses a statistical model (infrequently updated) for source "attack" node country of origin & frequency while destinations are fully randomized. The default sound is a Star Wars "blaster" (guess which one!). Sounds can be customized and an organization name can be specified, plus there are a few other <i>interesting</i> options.<br/>
<br/>
Check out the <a target=_blank href='http://github.com/hrbrmstr/pewpew'>github repository</a> for more information and instructions on how to customize the map options for maximum effect.<br/>
<br/>
Brought to you by <a target=_blank href="http://twitter.com/alexcpsec">@alexcpsec</a>, <a target=_blank href="http://twitter.com/hrbrmstr">@hrbrmstr</a> & <a target=_blank href="https://datadrivensecurity.info/blog/pages/resources.html">Data Driven Security</a>
</div>
<!-- Use Hash-Bang to maintain scroll position when closing modal -->
<a href="#!" class="modal-close" title="Close this modal"
data-dismiss="modal" data-close="Close">×</a>
<script>
// setup default min/max timer range for random draw
attack_min = 100 ;
attack_max = 2000 ;
// add/change the attack types here
attack_type = [ "any port scan in a storm", "ssh brutish force", "Thought Leader Tweet",
"SYN FLOOD BA-BY", "Spotty", "Heartbleed Hotel", "Po_ODLE", "Sharknado",
"CORGI Attack", "Ping of DOOM", "Conficker", "Goldfinger", "SANDPAPER",
"SNAILshock", "Spaghetti RAT", "Driduplex" ] ;
// gotta add types here if you add more sounds (or delete them)
audio_type = [ "starwars", "tng", "b5", "wargames", "pew", "galaga", "asteroids", "china", "timallen" ]
// need this to more easily grab URI query parameters
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
// here is where we deal with parameters
// try to grab them, see if they exist, make changes to defaults if they do
var norse_mode = $.getUrlVar('norse_mode');
var bad_day = $.getUrlVar('bad_day');
var org_name = $.getUrlVar('org_name');
var chatt_mode = $.getUrlVar('chatt_mode');
var china_mode = $.getUrlVar('china_mode');
var dprk_mode = $.getUrlVar('dprk_mode');
var employee_mode = $.getUrlVar('employee_mode');
var employee_fname = $.getUrlVar('employee_fname');
var employee_lname = $.getUrlVar('employee_lname');
var origin = $.getUrlVar('origin');
var random_mode = $.getUrlVar('random_mode');
var tng = $.getUrlVar('tng');
var wargames = $.getUrlVar('wargames');
var b5 = $.getUrlVar('b5');
var nofx = $.getUrlVar('nofx');
var pew = $.getUrlVar('pew');
var allfx = $.getUrlVar('allfx')
var galaga = $.getUrlVar('galaga')
var asteroids = $.getUrlVar('asteroids')
var china = $.getUrlVar('china')
var timallen = $.getUrlVar('timallen')
var drill_mode = $.getUrlVar("drill_mode")
var in_lat = $.getUrlVar("lat")
var in_lon = $.getUrlVar("lon")
var destination = $.getUrlVar("destination")
var greenattacks = $.getUrlVar("greenattacks")
var redattacks = $.getUrlVar("redattacks")
snd_id = "starwars" ;
if (typeof tng !== 'undefined') { snd_id = "tng" ; }
if (typeof b5 !== 'undefined') { snd_id = "b5" ; }
if (typeof wargames !== 'undefined') { snd_id = "wargames" ; }
if (typeof pew !== 'undefined') { snd_id = "pew" ; }
if (typeof galaga !== 'undefined') { snd_id = "galaga" ; }
if (typeof asteroids !== 'undefined') { snd_id = "asteroids" ; }
if (typeof china !== 'undefined') { snd_id = "china" ; }
if (typeof timallen !== 'undefined') { snd_id = "timallen" ; }
if (typeof bad_day !== 'undefined') {
attack_min=200;
attack_max=200;
}
if (typeof org_name !== 'undefined') { $("#titlediv").text(decodeURI(org_name) + " IPew Attack Map").html() }
// we maintain a fixed queue of "attacks" via this class
function FixedQueue( size, initialValues ){
initialValues = (initialValues || []);
var queue = Array.apply( null, initialValues );
queue.fixedSize = size;
queue.push = FixedQueue.push;
queue.splice = FixedQueue.splice;
queue.unshift = FixedQueue.unshift;
FixedQueue.trimTail.call( queue );
return( queue );
}
FixedQueue.trimHead = function(){
if (this.length <= this.fixedSize){ return; }
Array.prototype.splice.call( this, 0, (this.length - this.fixedSize) );
};
FixedQueue.trimTail = function(){
if (this.length <= this.fixedSize) { return; }
Array.prototype.splice.call( this, this.fixedSize, (this.length - this.fixedSize)
);
};
FixedQueue.wrapMethod = function( methodName, trimMethod ){
var wrapper = function(){
var method = Array.prototype[ methodName ];
var result = method.apply( this, arguments );
trimMethod.call( this );
return( result );
};
return( wrapper );
};
FixedQueue.push = FixedQueue.wrapMethod( "push", FixedQueue.trimHead );
FixedQueue.splice = FixedQueue.wrapMethod( "splice", FixedQueue.trimTail );
FixedQueue.unshift = FixedQueue.wrapMethod( "unshift", FixedQueue.trimTail );
var rand = function(min, max) {
return Math.random() * (max - min) + min;
};
var getRandomCountry = function(countries, weight) {
var total_weight = weight.reduce(function (prev, cur, i, arr) {
return prev + cur;
});
var random_num = rand(0, total_weight);
var weight_sum = 0;
for (var i = 0; i < countries.length; i++) {
weight_sum += weight[i];
weight_sum = +weight_sum.toFixed(2);
if (random_num <= weight_sum) {
return countries[i];
}
}
};
// need to make this dynamic since it is approximated from sources
var countries = [9,22,29,49,56,58,78,82,102,117,139,176,186] ;
var weight = [0.000,0.001,0.004,0.008,0.009,0.037,0.181,0.002,0.000,0.415,0.006,0.075,0.088];
// the fun begins!
//
// pretty simple setup ->
// * make base Datamap
// * setup timers to add random events to a queue
// * update the Datamap
var map = new Datamap({
scope: 'world',
element: document.getElementById('container1'),
projection: 'winkel3',
// change the projection to something else only if you have absolutely no cartographic sense
fills: { defaultFill: 'black', },
geographyConfig: {
dataUrl: null,
hideAntarctica: true,
borderWidth: 0.75,
borderColor: '#4393c3',
popupTemplate: function(geography, data) {
return '<div class="hoverinfo" style="color:white;background:black">' +
geography.properties.name + '</div>';
},
popupOnHover: true,
highlightOnHover: false,
highlightFillColor: 'black',
highlightBorderColor: 'rgba(250, 15, 160, 0.2)',
highlightBorderWidth: 2
},
})
// we read in a modified file of all country centers
var centers = [] ;
d3.tsv("country_centroids_primary.csv", function(data) { centers = data; });
d3.csv("samplatlong.csv", function(data) { slatlong = data; });
d3.csv("cnlatlong.csv", function(data) { cnlatlong = data; });
// setup structures for the "hits" (arcs)
// and circle booms
var hits = FixedQueue( 7, [ ] );
var boom = FixedQueue( 7, [ ] );
// we need random numbers and also a way to build random ip addresses
function getRandomInt(min, max) {return Math.floor(Math.random() * (max - min + 1)) + min;}
function getOctet() {return Math.round(Math.random()*255);}
function randomIP () { return(getOctet() + '.' + getOctet() + '.' + getOctet() + '.' + getOctet()); }
function getStroke() {return Math.round(Math.random()*100);}
function getDestination() {return Math.round(Math.random()*100);}
// doing this a bit fancy for a hack, but it makes it
// easier to group code functions together and have variables
// out of global scope
var attacks = {
interval: getRandomInt(attack_min, attack_max),
init: function(){
setTimeout(
jQuery.proxy(this.getData, this),
this.interval
);
},
getData: function() {
var self = this;
if (typeof norse_mode !== 'undefined') { return; }
if (typeof random_mode !== 'undefined') { Math.floor((Math.random() * slatlong.length)); }
dst = Math.floor((Math.random() * slatlong.length));
src = Math.floor((Math.random() * slatlong.length));
if ((dst == src)) {
dst = src + 1 ;
if (dst > slatlong.length-1) { dst = src - 1 }
}
if (typeof allfx !== 'undefined') {
snd_id = audio_type[Math.floor((Math.random() * audio_type.length))];
}
// no guarantee of sound playing w/o the load - stupid browsers
if (typeof nofx === 'undefined') {
document.getElementById(snd_id).load();
document.getElementById(snd_id).play();
}
// add hit to the arc queue
// use strokeColor to set arc line color
var srclat = slatlong[src].lat;
var srclong = slatlong[src].long;
var dstlat = slatlong[dst].lat;
var dstlong = slatlong[dst].long;
which_attack = attack_type[Math.floor((Math.random() * attack_type.length))];
var srccountry = slatlong[src]["country"];
// "Hi, Mandiant!!"
if (typeof china_mode !== 'undefined') {
srclat = cnlatlong[src].lat;
srclong = cnlatlong[src].long;
if (cnlatlong[src].country=="chn") { which_attack = "ZOMGOSH CHINA!!!!!!"; }
srccountry = cnlatlong[src]["country"];
}
// "Hi, Kim Jong!"
else if (typeof dprk_mode !== 'undefined') {
srclat = 39.0194;
srclong = 125.7381;
which_attack = "ZOMG NORTH KOREAZ!!!";
srccountry = "kp";
}
// source is always Chattanooga if chatt_mode is set
// "Hi ThreatStream!!" http://www.csoonline.com/article/2689609/network-security/threat-intelligence-firm-mistakes-research-for-nation-state-attack.html
else if (typeof chatt_mode !== 'undefined') {
srclat = 35.0456297;
srclong = -85.30968;
which_attack = "OMG NATION STATE CHATTANOOGA!!!";
srccountry = "usa";
}
// blame a former employee
else if (typeof employee_mode !== 'undefined') {
if (typeof in_lat !== 'undefined' && typeof in_lon !== 'undefined') {
srclat = in_lat;
srclong = in_lon;
}
which_attack = "Former employee attack"
if (typeof employee_fname !== 'undefined' && typeof employee_lname !== 'undefined') {
which_attack += ":" + employee_fname + " " + employee_lname;
}
srccountry = "usa";
}
// Specify a country
else if (typeof origin !== 'undefined') {
srccountry = origin.toUpperCase();
var center_id = 0;
for (i = 0; i < centers.length; i ++) {
center_id = i;
if (centers[i].FIPS10 === srccountry) {
break;
}
}
srccountry = origin.toLowerCase();
srclat = centers[center_id].LAT;
srclong = centers[center_id].LONG;
}
// Specify a destination country
if (typeof destination !== 'undefined' && getDestination() < 80) {
dstcountry = destination.toUpperCase();
var center_id = 0;
for (i = 0; i < centers.length; i ++) {
center_id = i;
if (centers[i].FIPS10 === dstcountry) {
break;
}
}
dstcountry = destination.toLowerCase();
attackdiv_slatlong = dstcountry;
dstlat = centers[center_id].LAT;
dstlong = centers[center_id].LONG;
}
else {
attackdiv_slatlong = slatlong[dst]["country"];
}
// Specify attack color
if (typeof greenattacks !== 'undefined') {
strokeColor = 'green';
}
else if (typeof redattacks !== 'undefined') {
strokeColor = 'red';
}
else {
if (getStroke() < 70) {
strokeColor = 'green';
}
else {
strokeColor = 'red';
}
}
if (typeof drill_mode != 'undefined') {
dstlat = in_lat
dstlong = in_lon
}
//only attempt to queue draws if the page is not hidden;
//trying to draw while the page is hidden causes the JS heap to balloon rapidly
if(!document.hidden) {
hits.push({
origin: {latitude: +srclat, longitude: +srclong},
destination: {latitude: +dstlat, longitude: +dstlong}
});
map.arc(hits, {strokeWidth: 2, strokeColor: strokeColor});
// add boom to the bubbles queue
boom.push({
radius: 7, latitude: +dstlat, longitude: +dstlong,
fillOpacity: 0.5, attk: which_attack
});
map.bubbles(boom, {
popupTemplate: function (geo, data) {
return '<div class="hoverinfo">' + data.attk + '</div>';
}
});
// update the scrolling attack div
$('#attackdiv').append(srccountry + " (" + randomIP() + ") " +
" <span style='color:red'>attacks</span> " +
attackdiv_slatlong + " (" + randomIP() + ") " +
" <span style='color:steelblue'>(" + which_attack + ")</span> " +
"<br/>");
$('#attackdiv').animate({scrollTop: $('#attackdiv').prop("scrollHeight")}, 500);
}
// pick a new random time and start the timer again!
this.interval = getRandomInt(attack_min, attack_max);
this.init() ;
},
};
// start the ball rolling!
attacks.init();
// lazy-dude's responsive window
d3.select(window).on('resize', function() { location.reload(); });
</script>
</body>
</html>