forked from fw42/honeymap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
js | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
config = | ||
port: 80 | ||
uid: 1000 | ||
hpfeeds: | ||
server: 'hpfeeds.honeycloud.net' | ||
port: 20000 | ||
ident: 'MyUsername' | ||
auth: 'MyPassword' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### | ||
Honeymap server for serving hpfeeds GPS streams | ||
### | ||
|
||
class HoneymapServer | ||
constructor: (config) -> | ||
hpfeeds = require('hpfeeds') | ||
sanitize = require('validator').sanitize | ||
http = new HttpServer(config.port) | ||
http.listen() | ||
transport = new Transport(http) | ||
feedconn = new hpfeeds.HPC( | ||
config.hpfeeds.server, | ||
config.hpfeeds.port, | ||
config.hpfeeds.ident, | ||
config.hpfeeds.auth | ||
) | ||
feedconn.onready -> feedconn.subscribe('geoloc.events') | ||
feedconn.msgcb = (id, chan, data) -> | ||
return unless data | ||
transport.broadcast(chan, { | ||
latitude: data.latitude | ||
longitude: data.longitude | ||
countrycode: data.countrycode | ||
city: data.city | ||
|
||
latitude2: data.latitude2 | ||
longitude2: data.longitude2 | ||
countrycode2: data.countrycode2 | ||
city2: data.city2 | ||
|
||
type: if data.type then sanitize(data.type).xss() else null | ||
md5: if data.md5 then sanitize(data.md5).xss() else null | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### | ||
Example honeymap server for serving random markers | ||
### | ||
|
||
class HoneymapServer | ||
constructor: (config) -> | ||
http = new HttpServer(config.port) | ||
http.listen() | ||
transport = new Transport(http) | ||
|
||
randomPoint = -> | ||
lat = Math.random() * 180 - 90 | ||
lng = Math.random() * 360 - 180 | ||
transport.broadcast("geoloc.events", { lat: lat, lng: lng, type: "random_remote" }) | ||
|
||
setInterval((-> setTimeout(randomPoint, Math.random() * 1000) ), 500) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class HoneymapServer | ||
constructor: (config) -> | ||
http = new HttpServer(config.port) | ||
http.listen() | ||
transport = new Transport(http) | ||
|
||
dgram = require("dgram") | ||
geoip = require('geoip-lite') | ||
udpserver = dgram.createSocket("udp4") | ||
udpserver.bind(41234) | ||
|
||
udpserver.on "listening", -> | ||
address = udpserver.address() | ||
console.log("udpserver listening " + address.address + ":" + address.port) | ||
|
||
udpserver.on "message", (msg, rinfo) -> | ||
console.log("server got: " + msg.toString() + " (" + typeof(msg) + ") from " + | ||
rinfo.address + ":" + rinfo.port) | ||
|
||
try | ||
msg = msg.toString() | ||
msg = msg.replace("\n", "") | ||
catch err | ||
console.log("msg error", err) | ||
return | ||
|
||
data = geoip.lookup(msg) | ||
# { range: [ 3479299040, 3479299071 ], | ||
# country: 'US', | ||
# region: 'CA', | ||
# city: 'San Francisco', | ||
# ll: [37.7484, -122.4156] } | ||
console.log(" -> lookup data:", data) | ||
return unless data | ||
transport.broadcast('geoloc.events', { | ||
latitude: data.ll[0] | ||
longitude: data.ll[1] | ||
countrycode: data.country | ||
city: data.city | ||
# latitude2: data.latitude2 | ||
# longitude2: data.longitude2 | ||
# countrycode2: data.countrycode2 | ||
# city2: data.city2 | ||
# type: data.type ? sanitize(data.type).xss() : null | ||
# md5: data.md5 ? sanitize(data.md5).xss() : null | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class HttpServer | ||
constructor: (port, cache) -> | ||
@http = require('http').createServer(@handler) | ||
@port = port || 80 | ||
@url = require('url') | ||
ns = require('node-static') | ||
@static = new(ns.Server)("../client", { cache: cache || 600 }) | ||
|
||
listen: -> | ||
@http.listen(@port) | ||
|
||
handler: (req, res) => | ||
try | ||
@static.serve req, res, (err, _) -> | ||
unless err | ||
HttpServer.log(req) | ||
return | ||
HttpServer.log(req, err.status) | ||
res.writeHead(err.status, err.headers) | ||
res.end() | ||
catch err | ||
console.error(err) | ||
res.writeHead(500) | ||
res.end('Internal Server Error') | ||
|
||
@log: (req, status) -> | ||
console.log("[HttpServer] %s:%d %s %s", | ||
req.connection.remoteAddress, req.connection.remotePort, status || "OK", req.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
honeymap = new HoneymapServer(config) | ||
process.setuid(config.uid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Transport | ||
constructor: (http) -> | ||
@socketio = require('socket.io').listen(http.http) | ||
|
||
# Production settings for socket.io | ||
@socketio.enable('browser client minification') # send minified client | ||
@socketio.enable('browser client etag') # apply etag caching logic based on version number | ||
@socketio.enable('browser client gzip') # gzip the file | ||
@socketio.set('log level', 1) # reduce logging | ||
|
||
# Clean up on disconnect | ||
@socketio.sockets.on 'connection', (socket) -> | ||
socket.on 'disconnect', -> | ||
delete socket.namespace.sockets[socket.id] | ||
|
||
broadcast: (instance, data) -> | ||
@socketio.sockets.emit(instance, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
cd $(dirname $0) | ||
node js/honeymap.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "HoneyMap", | ||
"preferGlobal": true, | ||
"version": "0.0.1", | ||
"author": "Mark Schloesser <ms@mwcollect.org>", | ||
"description": "a real-time world map which visualizes attacks captured by honeypots of the Honeynet Project", | ||
"contributors": [ | ||
{ | ||
"name": "Marak Schloesser", | ||
"email": "ms@mwcollect.org" | ||
}, | ||
{ | ||
"name": "Florian Weingarten", | ||
"email": "flo@hackvalue.de" | ||
}, | ||
{ | ||
"name": "Johannes Gilger", | ||
"email": "heipei@heipei.net" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fw42/honeymap.git" | ||
}, | ||
"keywords": [ | ||
"http", | ||
"server" | ||
], | ||
"dependencies" : { | ||
"coffee-script" : "*", | ||
"node-static" : "0.6.9", | ||
"socket.io" : "0.9.14", | ||
"validator" : "1.1.1" | ||
}, | ||
"license": "LGPL", | ||
"engines": { | ||
"node": ">=0.10" | ||
} | ||
} |