/*
UFONet - Denial of Service Toolkit - 2013/2018 - by psy (epsylon@riseup.net)
You should have received a copy of the GNU General Public License along
with UFONet; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// this variable defines the delay between each ajax update (statistics and geoip information)
var AJAX_DELAY = 1234
// interface control definitions, managed by leaflet
var UfoControlClass = L.Control.extend({
options: {
position: 'bottomright'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'ufo_msg_div leaflet-control-layers leaflet-control-layers-expanded')
L.DomEvent.on(container,'mousedown',L.DomEvent.stopPropagation)
.on(container,'doubleclick',L.DomEvent.stopPropagation)
.on(container,'click',L.DomEvent.stopPropagation)
return container;
}
});
var UfoTitleClass = L.Control.extend({
options: {
position: 'topleft'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'ufo_title_div leaflet-control-layers leaflet-control-layers-expanded')
return container;
}
});
var UfoErrorClass = L.Control.extend({
options: {
position: 'bottomleft'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'ufo_error_div leaflet-control-layers leaflet-control-layers-expanded')
return container;
}
});
var UfoStatClass = L.Control.extend({
options: {
position: 'bottomleft'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'ufo_stat_div leaflet-control-layers leaflet-control-layers-expanded')
L.DomEvent.on(container,'mousedown',L.DomEvent.stopPropagation)
.on(container,'doubleclick',L.DomEvent.stopPropagation)
.on(container,'click',L.DomEvent.stopPropagation)
return container;
}
});
// leaflet cluster, regrouping zombies by country
function Cluster(){
this._clusters=new Array()
this.add=function(zombie,marker){
cc=zombie.country_code
cg=false
if(cc){
cg=this.find(cc)
if(cg==false){
cg=new L.MarkerClusterGroup()
this._clusters.push({"cc":cc,"z":zombie,"cg":cg})
}
cg.addLayer(marker)
map.addLayer(cg)
}
}
this.find=function(cc){
for(c in this._clusters){
if(this._clusters[c].cc==cc){
return this._clusters[c].cg
}
}
return false
}
}
// Target object
function Doll(name){
this.name = name
this.data=false
this.latlong = false
this.city = false
this.country = false
this.country_code = false
this.asn = false
this.ip = false
this.hostname = false
this.drawnLayers = new Array()
this.show=function(){
target_icon=L.icon({iconUrl:"/js/leaflet/images/marker-icon.png",
iconSize: [25, 41],
iconAnchor: [13, 42],
popupAnchor: [-3, -76],
shadowUrl: '/js/leaflet/images/marker-shadow.png',
shadowSize: [68, 95],
shadowAnchor: [22, 94]
})
var marker = L.marker(this.latlong,{icon: target_icon})
var popup = L.Popup({
maxHeight: 50})
var popupcontent = ""+this.name+""
+"
-------------
"
+"Localisation: "+this.city+"/"+this.country
+"
"
+"IP: "+this.ip+"
"
+"Hostname: "+this.hostname+"
"
+"ASN: "+this.asn+"
"
marker.bindPopup(popupcontent)
this.drawnLayers.push(marker)
map.addLayer(marker)
}
this.setData = function(data){
this.data=data
this.latlong = data[0]
this.city = data[1]
this.country = data[2]
this.country_code = data[3]
this.asn = data[4]
this.ip = data[5]
this.hostname = data[6]
}
}
// object for each zombie
function zombieEntry(name,data){
this.data=data
this.name = name
this.latlong = data[0]
this.city = data[1]
this.country = data[2]
this.country_code = data[3]
this.asn = data[4]
this.ip = data[5]
this.hostname = data[6]
this.drawnLayers = new Array()
this.index=0
this.state='awakening'
this.speed= 1000 // animation speed in ms
this.cluster = false
this.show=function(){
if(this.state==='awakening'){
this.state='awake'
this.stop_anim=false
this.drawMarker()
}
}
this.drawMarker=function(){
if(!zombie_icon)
zombie_icon=L.icon({iconUrl:"/js/leaflet/images/ufonet-zombie.png",
iconSize: [16, 15],
iconAnchor: [8, 8],
popupAnchor: [-3, -76]
})
var marker = L.marker(this.latlong,{icon:zombie_icon}) //,{icon: this.makeCustomMarker()})
var popup = L.Popup({
maxHeight: 50})
var popupcontent = ""+this.name+""
+"
-------------
"
+"Localisation: "+this.city+"/"+this.country+"
"
+"IP: "+this.ip+"
"
+"Hostname: "+this.hostname+"
"
+"ASN: "+this.asn+"
"
marker.bindPopup(popupcontent)
cluster.add(this,marker)
this.drawnLayers.push(marker)
this.fire()
}
this.fire = function(){
if(doll){
var src = this.latlong
var dest = doll.latlong
var b = new R.BezierAnim([src, dest])
map.addLayer(b)
this.drawnLayers.push(b)
}
}
this.makeCustomMarker= function(){
if (this.index < this.counter_max){
var customIcon = new L.icon({
iconUrl: 'images/markers/marker-icon-'+this.index+'.png',
iconSize: [30, 30], // size of the icon
iconAnchor: [15, 15], // point of the icon which will correspond to marker's location
popupAnchor: [-150, 50] // point from which the popup should open relative to the iconAnchor
});
}
if (this.index == this.counter_max){
var customIcon = new L.icon({
iconUrl: 'images/markers/marker-icon-last.png',
iconSize: [30, 30], // size of the icon
iconAnchor: [15, 15], // point of the icon which will correspond to marker's location
popupAnchor: [-150, 0] // point from which the popup should open relative to the iconAnchor
});
}
return customIcon
}
this.makeClusterGroups=function(country_code_list){
for (var i = 0; i < this.unique_country_code_list.length; i++){
if (this.unique_country_code_list[i] == this.country_code_list[this.index]){
if (this.clusterGroups[this.unique_country_code_list[i]]){
//checks if a cluster for the country already exists
return
}
else
//if not make it.
this.clusterGroups[this.unique_country_code_list[i]] = new L.MarkerClusterGroup();
}
}
}
this.AddMarkerCluster= function(marker){
this.clusterGroups[this.country_code_list[this.index]].addLayer(marker)
map.addLayer(this.clusterGroups[this.country_code_list[this.index]])
this.drawnLayers.push(this.clusterGroups[this.country_code_list[this.index]])
}
this.AddMarker=function(src){
var marker = L.marker([src[0], src[1]],{icon: this.makeCustomMarker()})
this.drawnLayers.push(marker)
}
this.hide=function() {
$('.header').hide()
this.index =0
this.state='awakening'
this.stop_anim=true
for (i in this.drawnLayers){
if(map.hasLayer(this.drawnLayers[i]))
map.removeLayer(this.drawnLayers[i])
}
this.drawnLayers=new Array()
}
}
// List of zombies
function Herd(){
this.zombieEntries = new Array
this.find=function (name){
for (z in this.zombieEntries){
if (this.zombieEntries[z].name === name){
return this.zombieEntries[z]
}
}
return false;
}
this.load=function(name){
e=this.find(name)
if(e){
e.show()
return
}
return false
}
this.hideAll = function(){
for (ufoe in this.zombieEntries)
this.zombieEntries[ufoe].hide()
this.render()
}
this.hide = function(name){
var ufoe=this.find(name)
if(!ufoe) return
ufoe.hide()
this.render()
}
this.remove = function(name){
for (z in this.zombieEntries){
if(this.zombieEntries[z].name === name){
this.zombieEntries[z].hide()
this.zombieEntries.splice(z,1)
this.render()
return
}
}
}
this.add = function(name,data){
var ufoe=this.find(name)
if(!ufoe){
ufoe=new zombieEntry(name,data)
this.zombieEntries.push(ufoe)
}
ufoe.show()
return ufoe
}
this.stop=function() {
for(i=0;i