-
Notifications
You must be signed in to change notification settings - Fork 10
/
LongTail_make_map.pl
executable file
·75 lines (59 loc) · 1.64 KB
/
LongTail_make_map.pl
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
#!/usr/bin/perl
#
# This file assumes you are reading /var/www/html/honey/current-ip-addresses.txt
# or a similarly formatted file
#
if ( $ARGV[0] eq ""){
print (STDERR "You forgot to add a filename to your command, exiting now\n");
exit;
}
if (! -e $ARGV[0] ){
print (STDERR "filename $ARGV[0] does not exist, exiting now.\n");
exit;
}
print "
<script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>
<script type=\"text/javascript\">
google.load(\"visualization\", \"1\", {packages:[\"geochart\"]});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Country', 'Login Attempts', 'IP Addresses'],
";
open (FILE, $ARGV[0]);
while (<FILE>){
chomp;
if (/#/){next;}
$_ =~ s/\(..*\)//;
$_ =~ s/ $//;
$_ =~ s/^ +//;
($count,$ip,$country)=split (/ +/,$_);
if ($country eq "Hong_Kong"){$country="China";}
if ($country ne ""){
$attacks{$country}+=$count;
$ip_addresses{$country}+=1;
}
}
close (FILE);
$count=0;
foreach $name(keys %attacks){
$count++;
# if ($attacks{$name} > 100){
print "['$name', $attacks{$name}, $ip_addresses{$name} ],\n";
# }
}
if ($count <1){
print "['', 0, 0 ],\n";
}
print "
]);
var options = {
<!-- colorAxis: {colors: ['#00853f', 'black', '#e31b23']}, -->
<!--colorAxis: {colors: ['#000000', 'red', '#FF0000']},-->
colorAxis: {colors: ['#0000F0', '#FF0000']},
};
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
chart.draw(data, options);
}
</script>
";