From 32af49ddecc87a866a4b503e7fe0c15052b911cd Mon Sep 17 00:00:00 2001 From: Russ Handorf Date: Sat, 3 Feb 2018 23:10:42 -0500 Subject: [PATCH 1/1] initial commit --- README | 7 + honeymap-master/.gitignore | 1 + honeymap-master/LICENSE | 165 +++++ honeymap-master/Makefile | 16 + honeymap-master/Makefile.old | 17 + honeymap-master/README.md | 47 ++ honeymap-master/proxy/.gitignore | 1 + honeymap-master/proxy/README.md | 13 + honeymap-master/proxy/haproxy.cfg | 126 ++++ honeymap-master/proxy/proxy.js | 23 + honeymap-master/server/.gitignore | 3 + .../server/server_alienfeeds-pcap.js | 79 ++ honeymap-master/server/server_alienfeeds.js | 79 ++ .../server/server_alienfeeds.js.old | 78 ++ .../server/server_alienfeeds_config.js | 11 + honeymap-master/server/server_hpfeeds.js | 77 ++ .../server/server_hpfeeds_config.js.example | 10 + honeymap-master/server/server_random.js | 39 + honeymap-master/static/.gitignore | 1 + honeymap-master/static/404.html | 0 honeymap-master/static/500.html | 0 honeymap-master/static/extern/bootstrap.js | 335 +++++++++ .../static/extern/bootstrap.min.css | 329 +++++++++ .../static/extern/jquery-1.7.2.min.js | 4 + .../static/extern/jquery-jvectormap-1.0.css | 37 + .../extern/jquery-jvectormap-1.0.min.js | 7 + .../extern/jquery-jvectormap-world-mill-en.js | 1 + .../static/extern/jquery-transit.js | 697 ++++++++++++++++++ honeymap-master/static/feed_random.js | 19 + .../static/feed_socketio_hpfeeds.js | 69 ++ .../static/feed_socketio_random.js | 10 + honeymap-master/static/google_analytics.js | 9 + honeymap-master/static/hm.js | 11 + honeymap-master/static/img/help.png | Bin 0 -> 5474 bytes honeymap-master/static/img/hp_logo.png | Bin 0 -> 21196 bytes honeymap-master/static/img/itsec_logo.png | Bin 0 -> 6099 bytes honeymap-master/static/index.html.compressed | 107 +++ honeymap-master/static/index.html.debug | 117 +++ honeymap-master/static/index.html.proxy | 107 +++ honeymap-master/static/layout.js | 18 + honeymap-master/static/main.css | 117 +++ honeymap-master/static/main.js | 122 +++ honeymap-master/static/main.js.bak | 122 +++ honeymap-master/static/map.js | 44 ++ honeymap-master/static/welcome.js | 3 + pcap-colors.pl | 76 ++ server.pl | 67 ++ 47 files changed, 3221 insertions(+) create mode 100644 README create mode 100644 honeymap-master/.gitignore create mode 100644 honeymap-master/LICENSE create mode 100644 honeymap-master/Makefile create mode 100644 honeymap-master/Makefile.old create mode 100644 honeymap-master/README.md create mode 100644 honeymap-master/proxy/.gitignore create mode 100644 honeymap-master/proxy/README.md create mode 100644 honeymap-master/proxy/haproxy.cfg create mode 100644 honeymap-master/proxy/proxy.js create mode 100644 honeymap-master/server/.gitignore create mode 100644 honeymap-master/server/server_alienfeeds-pcap.js create mode 100644 honeymap-master/server/server_alienfeeds.js create mode 100644 honeymap-master/server/server_alienfeeds.js.old create mode 100644 honeymap-master/server/server_alienfeeds_config.js create mode 100644 honeymap-master/server/server_hpfeeds.js create mode 100644 honeymap-master/server/server_hpfeeds_config.js.example create mode 100644 honeymap-master/server/server_random.js create mode 100644 honeymap-master/static/.gitignore create mode 100644 honeymap-master/static/404.html create mode 100644 honeymap-master/static/500.html create mode 100644 honeymap-master/static/extern/bootstrap.js create mode 100644 honeymap-master/static/extern/bootstrap.min.css create mode 100644 honeymap-master/static/extern/jquery-1.7.2.min.js create mode 100644 honeymap-master/static/extern/jquery-jvectormap-1.0.css create mode 100644 honeymap-master/static/extern/jquery-jvectormap-1.0.min.js create mode 100644 honeymap-master/static/extern/jquery-jvectormap-world-mill-en.js create mode 100644 honeymap-master/static/extern/jquery-transit.js create mode 100644 honeymap-master/static/feed_random.js create mode 100644 honeymap-master/static/feed_socketio_hpfeeds.js create mode 100644 honeymap-master/static/feed_socketio_random.js create mode 100644 honeymap-master/static/google_analytics.js create mode 100644 honeymap-master/static/hm.js create mode 100644 honeymap-master/static/img/help.png create mode 100644 honeymap-master/static/img/hp_logo.png create mode 100644 honeymap-master/static/img/itsec_logo.png create mode 100644 honeymap-master/static/index.html.compressed create mode 100644 honeymap-master/static/index.html.debug create mode 100644 honeymap-master/static/index.html.proxy create mode 100644 honeymap-master/static/layout.js create mode 100644 honeymap-master/static/main.css create mode 100644 honeymap-master/static/main.js create mode 100644 honeymap-master/static/main.js.bak create mode 100644 honeymap-master/static/map.js create mode 100644 honeymap-master/static/welcome.js create mode 100755 pcap-colors.pl create mode 100755 server.pl diff --git a/README b/README new file mode 100644 index 0000000..a4effa3 --- /dev/null +++ b/README @@ -0,0 +1,7 @@ +Compile the honeymap-master stuff. I've lightly edited it for this purpose. + +Use the version that is: + +server_alienfeeds-pcap.js + +Then start the server script, and start the sniffer script. Navigate to the webpage as described in the Node engine, and you've got pew pew. diff --git a/honeymap-master/.gitignore b/honeymap-master/.gitignore new file mode 100644 index 0000000..e45c9c2 --- /dev/null +++ b/honeymap-master/.gitignore @@ -0,0 +1 @@ +other diff --git a/honeymap-master/LICENSE b/honeymap-master/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/honeymap-master/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/honeymap-master/Makefile b/honeymap-master/Makefile new file mode 100644 index 0000000..e24f08a --- /dev/null +++ b/honeymap-master/Makefile @@ -0,0 +1,16 @@ +YUICOMPRESSOR ?= /usr/bin/yui-compressor + +all: hm.js + +hm.js: all.js + $(YUICOMPRESSOR) -o static/hm.js all.js + rm all.js + +all.js: + cat static/extern/jquery-*.js static/main.js static/layout.js static/extern/bootstrap.js static/feed_socketio_random.js static/map.js > all.js + +clean: + rm -f static/hm.js + +.PHONY: all clean + diff --git a/honeymap-master/Makefile.old b/honeymap-master/Makefile.old new file mode 100644 index 0000000..19da79f --- /dev/null +++ b/honeymap-master/Makefile.old @@ -0,0 +1,17 @@ +YUICOMPRESSOR ?= /usr/bin/yui-compressor + +all: hm.js + +hm.js: all.js + $(YUICOMPRESSOR) -o static/hm.js all.js + #java -jar $(YUICOMPRESSOR) -o static/hm.js all.js + rm all.js + +all.js: + cat static/extern/jquery-*.js static/main.js static/layout.js static/extern/bootstrap.js static/feed_socketio_hpfeeds.js static/map.js > all.js + +clean: + rm -f static/hm.js + +.PHONY: all clean + diff --git a/honeymap-master/README.md b/honeymap-master/README.md new file mode 100644 index 0000000..4643665 --- /dev/null +++ b/honeymap-master/README.md @@ -0,0 +1,47 @@ +HoneyMap +======== + +HoneyMap is a web application which displays a live stream of +GPS locations on a SVG world map. It makes use of +[jQuery](http://jquery.com/), +[node.js](http://nodejs.org/), +[socket.io](http://socket.io/) (HTML5 websockets), +[jVectorMap](http://jvectormap.com/) and +[jQuery Transit](http://ricostacruz.com/jquery.transit/) for CSS3 animations. + +In principle, it can be used with any stream of GPS data. For our application, +we use honeypot captures, provided by several [hpfeeds](https://github.com/rep/hpfeeds) +from the [Honeynet Project](http://www.honeynet.org/). + +Tested with node.js v0.8.9 and socket.io v0.9.10. + +Example +------- +* [http://map.honeycloud.net/](http://map.honeycloud.net/) + +Requirements +------------ +* `npm install node-static` +* `npm install socket.io` +* `npm install validator` + +Browser support +--------------- +Should work with current Chrome and Firefox browsers. +Opera, Safari and IE not tested yet. + +License +------- +GNU Lesser General Public License (LGPL), see +[LICENSE](http://github.com/fw42/honeymap/blob/master/LICENSE). + +Authors +------- +* [Florian Weingarten](mailto:flo@hackvalue.de) ([fw42](http://github.com/fw42/)) +* [Mark Schloesser](mailto:mark.schloesser@rwth-aachen.de) ([rep](http://github.com/rep/)) + +TODO +---- +* Make maximal number of visible markers configurable by user +* "Replay" feature (load last x hours from server) +* Browser compatibility (only Webkit and Firefox right now; No Mobile browsers) diff --git a/honeymap-master/proxy/.gitignore b/honeymap-master/proxy/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/honeymap-master/proxy/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/honeymap-master/proxy/README.md b/honeymap-master/proxy/README.md new file mode 100644 index 0000000..2544b66 --- /dev/null +++ b/honeymap-master/proxy/README.md @@ -0,0 +1,13 @@ +HoneyMap nodejs-http-proxy +========================== + +Use this to multiplex nginx (for static content) and +the honeymap nodejs backend (for socket.io content) +on the same port (80). + +HAProxy HTTP/WebSocket multiplexing +=================================== + +Alternatively you can use the haproxy.cfg in this directory to offer HTTP and +Websockets on the same frontend port, with the services in the backend running +on different ports. diff --git a/honeymap-master/proxy/haproxy.cfg b/honeymap-master/proxy/haproxy.cfg new file mode 100644 index 0000000..db4e56b --- /dev/null +++ b/honeymap-master/proxy/haproxy.cfg @@ -0,0 +1,126 @@ +# this config needs haproxy-1.1.28 or haproxy-1.2.1 + +#global +# log 127.0.0.1 local0 +# log 127.0.0.1 local1 notice +# #log loghost local0 info +# maxconn 4096 +# #chroot /usr/share/haproxy +# user haproxy +# group haproxy +# daemon +# #debug +# #quiet +# +#defaults +# log global +# mode http +# option httplog +# option dontlognull +# retries 3 +# option redispatch +# maxconn 2000 +# contimeout 5000 +# clitimeout 50000 +# srvtimeout 50000 +# +#listen appli1-rewrite 0.0.0.0:10001 +# cookie SERVERID rewrite +# balance roundrobin +# server app1_1 192.168.34.23:8080 cookie app1inst1 check inter 2000 rise 2 fall 5 +# server app1_2 192.168.34.32:8080 cookie app1inst2 check inter 2000 rise 2 fall 5 +# server app1_3 192.168.34.27:8080 cookie app1inst3 check inter 2000 rise 2 fall 5 +# server app1_4 192.168.34.42:8080 cookie app1inst4 check inter 2000 rise 2 fall 5 +# +#listen appli2-insert 0.0.0.0:10002 +# option httpchk +# balance roundrobin +# cookie SERVERID insert indirect nocache +# server inst1 192.168.114.56:80 cookie server01 check inter 2000 fall 3 +# server inst2 192.168.114.56:81 cookie server02 check inter 2000 fall 3 +# capture cookie vgnvisitor= len 32 +# +# option httpclose # disable keep-alive +# rspidel ^Set-cookie:\ IP= # do not let this cookie tell our internal IP address +# +#listen appli3-relais 0.0.0.0:10003 +# dispatch 192.168.135.17:80 +# +#listen appli4-backup 0.0.0.0:10004 +# option httpchk /index.html +# option persist +# balance roundrobin +# server inst1 192.168.114.56:80 check inter 2000 fall 3 +# server inst2 192.168.114.56:81 check inter 2000 fall 3 backup +# +#listen ssl-relay 0.0.0.0:8443 +# option ssl-hello-chk +# balance source +# server inst1 192.168.110.56:443 check inter 2000 fall 3 +# server inst2 192.168.110.57:443 check inter 2000 fall 3 +# server back1 192.168.120.58:443 backup +# +#listen appli5-backup 0.0.0.0:10005 +# option httpchk * +# balance roundrobin +# cookie SERVERID insert indirect nocache +# server inst1 192.168.114.56:80 cookie server01 check inter 2000 fall 3 +# server inst2 192.168.114.56:81 cookie server02 check inter 2000 fall 3 +# server inst3 192.168.114.57:80 backup check inter 2000 fall 3 +# capture cookie ASPSESSION len 32 +# srvtimeout 20000 +# +# option httpclose # disable keep-alive +# option checkcache # block response if set-cookie & cacheable +# +# rspidel ^Set-cookie:\ IP= # do not let this cookie tell our internal IP address +# +# #errorloc 502 http://192.168.114.58/error502.html +# #errorfile 503 /etc/haproxy/errors/503.http +# errorfile 400 /etc/haproxy/errors/400.http +# errorfile 403 /etc/haproxy/errors/403.http +# errorfile 408 /etc/haproxy/errors/408.http +# errorfile 500 /etc/haproxy/errors/500.http +# errorfile 502 /etc/haproxy/errors/502.http +# errorfile 503 /etc/haproxy/errors/503.http +# errorfile 504 /etc/haproxy/errors/504.http + +global + maxconn 4096 + daemon + user www-data + group www-data + +defaults + mode http + log 127.0.0.1 local1 debug + option httplog + +frontend all 0.0.0.0:80 + timeout client 100000 + default_backend www_backend + acl is_websocket hdr(Upgrade) -i WebSocket + acl is_websocket path_beg /socket.io/ + + use_backend socket_backend if is_websocket + +backend www_backend + balance roundrobin + option forwardfor # This sets X-Forwarded-For + option httpclose + timeout server 30000 + timeout connect 5000 + server server1 localhost:81 weight 1 maxconn 1024 check + +backend socket_backend + balance roundrobin + option forwardfor # This sets X-Forwarded-For + option httpclose + timeout queue 5000 + timeout server 86400000 + timeout connect 5000 + server server1 localhost:82 weight 1 maxconn 2048 check + +listen admin + bind *:8080 + stats enable diff --git a/honeymap-master/proxy/proxy.js b/honeymap-master/proxy/proxy.js new file mode 100644 index 0000000..bb0b6b8 --- /dev/null +++ b/honeymap-master/proxy/proxy.js @@ -0,0 +1,23 @@ +var http = require('http'), httpProxy = require('http-proxy'); + +var backend_nginx = new httpProxy.HttpProxy({ target: { host: 'localhost', port: 81 } }); +var backend_socketio = new httpProxy.HttpProxy({ target: { host: 'localhost', port: 82 }}); + +// Redirect socket.io requests to socket.io and static content to nginx +var server = http.createServer(function(req, res) { + if(req.url.match(/^\/socket\.io\//)) { + backend_socketio.proxyRequest(req, res); + } else { + backend_nginx.proxyRequest(req, res); + } +}); + +// Redirect websocket requests to the socket.io server +server.on('upgrade', function(req, socket, head) { + backend_socketio.proxyWebSocketRequest(req, socket, head); +}); + +server.listen(80); + +// Drop privileges +process.setuid(1000); diff --git a/honeymap-master/server/.gitignore b/honeymap-master/server/.gitignore new file mode 100644 index 0000000..e0e754b --- /dev/null +++ b/honeymap-master/server/.gitignore @@ -0,0 +1,3 @@ +node_modules +server_hpfeeds_config.js +log.txt diff --git a/honeymap-master/server/server_alienfeeds-pcap.js b/honeymap-master/server/server_alienfeeds-pcap.js new file mode 100644 index 0000000..7087ae2 --- /dev/null +++ b/honeymap-master/server/server_alienfeeds-pcap.js @@ -0,0 +1,79 @@ +/** Example node.js app for serving random markers via socket.io **/ + +var app = require('http').createServer(handler); +var fs = require('fs'); +var util = require('util'); +var ns = require('node-static'); +var io = require('socket.io').listen(app); +var net = require('net'); +var file = new(ns.Server)("../static/", { cache: 600 }); + +// Listen on port 1337 +app.listen(1338); + +// Serve static content +function handler (req, res) { + req.addListener('end', function() { + file.serve(req, res, function(err, result) { + if (err) { + console.error('Error serving %s - %s', req.url, err.message); + if (err.status === 404 || err.status === 500) { + file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res); + } else { + res.writeHead(err.status, err.headers); + res.end(); + } + } + }); + }); +} + +// Push random markers via socket.io +io.sockets.on('connection', function (socket) { + //function random_point() { + // var lat, lng; + // lat = Math.random() * 180 - 90; + // lng = Math.random() * 360 - 180; + // socket.emit('marker', { lat: lat, lng: lng }); + // } + + //function insert_point(lat,lng) { + // socket.emit('marker', { lat: lat, lng: lng }); + //} + + var sock = net.createConnection(10000,"localhost"); + console.log('Attempting a connection'); + sock.on('connect', function (connect) { + console.log('Connected'); + sock.on('data', function (data) { + // var data = c + ''; // make sure it's a string + //var tmp = data.toString("utf-8").split("\n"); + //console.log('data`%s`', tmp[0]); + //var parts = tmp[0].split(":"); + var parts = data.toString("utf-8").split(":"); + var lat, lng; + lat = Number(parts[0]); + lng = Number(parts[1]); + if (lat != null && lng != null) { + //console.log('split lat: %s long: %s', parts[0], parts[1]); + //lat.replace(/(\n|\r|\r\n)$/, ''); + //lat.replace(/(\n|\r|\r\n)$/, ''); + //lng.replace(/(\n|\r|\r\n)$/, ''); + //lng.trim; + //console.log('passed lat: %s long: %s', lat, lng); + //console.log('Received data: `%s`', data); + //insert_point(lat,lng); + //lat=37.0000; + //lng=127.5000; + socket.emit('marker', { lat: lat, lng: lng }); + } + //} + }) + //socket.on("end", function () { + //// ITS OVER! + //}) + }); + + + //setInterval(function() { setTimeout(random_point, Math.random() * 1000) }, 500); +}); diff --git a/honeymap-master/server/server_alienfeeds.js b/honeymap-master/server/server_alienfeeds.js new file mode 100644 index 0000000..719b561 --- /dev/null +++ b/honeymap-master/server/server_alienfeeds.js @@ -0,0 +1,79 @@ +/** Example node.js app for serving random markers via socket.io **/ + +var app = require('http').createServer(handler); +var fs = require('fs'); +var util = require('util'); +var ns = require('node-static'); +var io = require('socket.io').listen(app); +var net = require('net'); +var file = new(ns.Server)("../static/", { cache: 600 }); + +// Listen on port 1337 +app.listen(1337); + +// Serve static content +function handler (req, res) { + req.addListener('end', function() { + file.serve(req, res, function(err, result) { + if (err) { + console.error('Error serving %s - %s', req.url, err.message); + if (err.status === 404 || err.status === 500) { + file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res); + } else { + res.writeHead(err.status, err.headers); + res.end(); + } + } + }); + }); +} + +// Push random markers via socket.io +io.sockets.on('connection', function (socket) { + //function random_point() { + // var lat, lng; + // lat = Math.random() * 180 - 90; + // lng = Math.random() * 360 - 180; + // socket.emit('marker', { lat: lat, lng: lng }); + // } + + //function insert_point(lat,lng) { + // socket.emit('marker', { lat: lat, lng: lng }); + //} + + var sock = net.createConnection(10000,"localhost"); + console.log('Attempting a connection'); + sock.on('connect', function (connect) { + console.log('Connected'); + sock.on('data', function (data) { + // var data = c + ''; // make sure it's a string + //var tmp = data.toString("utf-8").split("\n"); + //console.log('data`%s`', tmp[0]); + //var parts = tmp[0].split(":"); + var parts = data.toString("utf-8").split(":"); + var lat, lng; + lat = Number(parts[0]); + lng = Number(parts[1]); + if (lat != null && lng != null) { + //console.log('split lat: %s long: %s', parts[0], parts[1]); + //lat.replace(/(\n|\r|\r\n)$/, ''); + //lat.replace(/(\n|\r|\r\n)$/, ''); + //lng.replace(/(\n|\r|\r\n)$/, ''); + //lng.trim; + //console.log('passed lat: %s long: %s', lat, lng); + //console.log('Received data: `%s`', data); + //insert_point(lat,lng); + //lat=37.0000; + //lng=127.5000; + socket.emit('marker', { lat: lat, lng: lng }); + } + //} + }) + //socket.on("end", function () { + //// ITS OVER! + //}) + }); + + + //setInterval(function() { setTimeout(random_point, Math.random() * 1000) }, 500); +}); diff --git a/honeymap-master/server/server_alienfeeds.js.old b/honeymap-master/server/server_alienfeeds.js.old new file mode 100644 index 0000000..fe75588 --- /dev/null +++ b/honeymap-master/server/server_alienfeeds.js.old @@ -0,0 +1,78 @@ +var sys = require('sys'); +var url = require('url'); +var app = require('http').createServer(handler); +var fs = require('fs'); +var util = require('util'); +var ns = require('node-static'); +var io = require('socket.io').listen(app); +var hpfeeds = require('alienfeeds'); +var file = new(ns.Server)("../static/", { cache: 600 }); +var sanitize = require('validator').sanitize; + +eval(fs.readFileSync('server_hpfeeds_config.js').toString()); + +// Listen and drop privileges +app.listen(config.port); +process.setuid(config.uid); + +// Production settings for socket.io +io.enable('browser client minification'); // send minified client +io.enable('browser client etag'); // apply etag caching logic based on version number +io.enable('browser client gzip'); // gzip the file +io.set('log level', 1); // reduce logging + +// hp feed +var feedconn = new alienfeeds.HPC( + config.alienfeeds.server, + condig.alienfeeds.port + //config.hpfeeds.port, + //config.hpfeeds.ident, + //config.hpfeeds.auth +); +feedconn.onready(function() { feedconn.subscribe('geoloc.events'); }); + +// Serve static content +function handler (req, res) { + try { + console.log('New request: ' + req.connection.remoteAddress + ': ' + url.parse(req.url).href); + req.addListener('end', function() { + file.serve(req, res, function(err, result) { + if (err) { + console.error('Error serving %s: %s', req.url, err.message); + if (err.status === 404 || err.status === 500) { + file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res); + } else { + res.writeHead(err.status, err.headers); + res.end(); + } + } + }); + }); + } catch(err) { + sys.puts(err); + res.writeHead(500); + res.end('Internal Server Error'); + } +} + +// Push feed data to all connected sockets +feedconn.msgcb = function(id, chan, data) { + if(data != null) { + io.sockets.emit('marker', { + latitude: data.latitude, longitude: data.longitude, + countrycode: data.countrycode, country: data.country, city: data.city, + + latitude2: data.latitude2, longitude2: data.longitude2, + countrycode2: data.countrycode2, country2: data.country2, city2: data.city2, + + type: data.type ? sanitize(data.type).xss() : null, + md5: data.md5 ? sanitize(data.md5).xss() : null + }); + } +} + +io.sockets.on('connection', function (socket) { + socket.on('disconnect', function() { + delete socket.namespace.sockets[socket.id]; + }) +}) diff --git a/honeymap-master/server/server_alienfeeds_config.js b/honeymap-master/server/server_alienfeeds_config.js new file mode 100644 index 0000000..d597e70 --- /dev/null +++ b/honeymap-master/server/server_alienfeeds_config.js @@ -0,0 +1,11 @@ +var config = { + port: 1337, + uid: 1000, + hpfeeds: { + server: 'localhost', + port: 10000 + //port: 10000, + //ident: 'MyUsername', + //auth: 'MyPassword' + } +}; diff --git a/honeymap-master/server/server_hpfeeds.js b/honeymap-master/server/server_hpfeeds.js new file mode 100644 index 0000000..e6e98c1 --- /dev/null +++ b/honeymap-master/server/server_hpfeeds.js @@ -0,0 +1,77 @@ +var sys = require('sys'); +var url = require('url'); +var app = require('http').createServer(handler); +var fs = require('fs'); +var util = require('util'); +var ns = require('node-static'); +var io = require('socket.io').listen(app); +var hpfeeds = require('hpfeeds'); +var file = new(ns.Server)("../static/", { cache: 600 }); +var sanitize = require('validator').sanitize; + +eval(fs.readFileSync('server_hpfeeds_config.js').toString()); + +// Listen and drop privileges +app.listen(config.port); +process.setuid(config.uid); + +// Production settings for socket.io +io.enable('browser client minification'); // send minified client +io.enable('browser client etag'); // apply etag caching logic based on version number +io.enable('browser client gzip'); // gzip the file +io.set('log level', 1); // reduce logging + +// hp feed +var feedconn = new hpfeeds.HPC( + config.hpfeeds.server, + config.hpfeeds.port, + config.hpfeeds.ident, + config.hpfeeds.auth +); +feedconn.onready(function() { feedconn.subscribe('geoloc.events'); }); + +// Serve static content +function handler (req, res) { + try { + console.log('New request: ' + req.connection.remoteAddress + ': ' + url.parse(req.url).href); + req.addListener('end', function() { + file.serve(req, res, function(err, result) { + if (err) { + console.error('Error serving %s: %s', req.url, err.message); + if (err.status === 404 || err.status === 500) { + file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res); + } else { + res.writeHead(err.status, err.headers); + res.end(); + } + } + }); + }); + } catch(err) { + sys.puts(err); + res.writeHead(500); + res.end('Internal Server Error'); + } +} + +// Push feed data to all connected sockets +feedconn.msgcb = function(id, chan, data) { + if(data != null) { + io.sockets.emit('marker', { + latitude: data.latitude, longitude: data.longitude, + countrycode: data.countrycode, country: data.country, city: data.city, + + latitude2: data.latitude2, longitude2: data.longitude2, + countrycode2: data.countrycode2, country2: data.country2, city2: data.city2, + + type: data.type ? sanitize(data.type).xss() : null, + md5: data.md5 ? sanitize(data.md5).xss() : null + }); + } +} + +io.sockets.on('connection', function (socket) { + socket.on('disconnect', function() { + delete socket.namespace.sockets[socket.id]; + }) +}) diff --git a/honeymap-master/server/server_hpfeeds_config.js.example b/honeymap-master/server/server_hpfeeds_config.js.example new file mode 100644 index 0000000..8dcb6c4 --- /dev/null +++ b/honeymap-master/server/server_hpfeeds_config.js.example @@ -0,0 +1,10 @@ +var config = { + port: 80, + uid: 1000, + hpfeeds: { + server: 'hpfeeds.honeycloud.net', + port: 10000, + ident: 'MyUsername', + auth: 'MyPassword' + } +}; diff --git a/honeymap-master/server/server_random.js b/honeymap-master/server/server_random.js new file mode 100644 index 0000000..b18f75c --- /dev/null +++ b/honeymap-master/server/server_random.js @@ -0,0 +1,39 @@ +/** Example node.js app for serving random markers via socket.io **/ + +var app = require('http').createServer(handler); +var fs = require('fs'); +var util = require('util'); +var ns = require('node-static'); +var io = require('socket.io').listen(app); +var file = new(ns.Server)("../static/", { cache: 600 }); + +// Listen on port 1337 +app.listen(1337); + +// Serve static content +function handler (req, res) { + req.addListener('end', function() { + file.serve(req, res, function(err, result) { + if (err) { + console.error('Error serving %s - %s', req.url, err.message); + if (err.status === 404 || err.status === 500) { + file.serveFile(util.format('/%d.html', err.status), err.status, {}, req, res); + } else { + res.writeHead(err.status, err.headers); + res.end(); + } + } + }); + }); +} + +// Push random markers via socket.io +io.sockets.on('connection', function (socket) { + function random_point() { + var lat, lng; + lat = Math.random() * 180 - 90; + lng = Math.random() * 360 - 180; + socket.emit('marker', { lat: lat, lng: lng }); + } + setInterval(function() { setTimeout(random_point, Math.random() * 1000) }, 500); +}); diff --git a/honeymap-master/static/.gitignore b/honeymap-master/static/.gitignore new file mode 100644 index 0000000..dcaf716 --- /dev/null +++ b/honeymap-master/static/.gitignore @@ -0,0 +1 @@ +index.html diff --git a/honeymap-master/static/404.html b/honeymap-master/static/404.html new file mode 100644 index 0000000..e69de29 diff --git a/honeymap-master/static/500.html b/honeymap-master/static/500.html new file mode 100644 index 0000000..e69de29 diff --git a/honeymap-master/static/extern/bootstrap.js b/honeymap-master/static/extern/bootstrap.js new file mode 100644 index 0000000..cd30b5d --- /dev/null +++ b/honeymap-master/static/extern/bootstrap.js @@ -0,0 +1,335 @@ +/* ========================================================= + * bootstrap-modal.js v2.1.1 + * http://twitter.github.com/bootstrap/javascript.html#modals + * ========================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* MODAL CLASS DEFINITION + * ====================== */ + + var Modal = function (element, options) { + this.options = options + this.$element = $(element) + .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) + this.options.remote && this.$element.find('.modal-body').load(this.options.remote) + } + + Modal.prototype = { + + constructor: Modal + + , toggle: function () { + return this[!this.isShown ? 'show' : 'hide']() + } + + , show: function () { + var that = this + , e = $.Event('show') + + this.$element.trigger(e) + + if (this.isShown || e.isDefaultPrevented()) return + + $('body').addClass('modal-open') + + this.isShown = true + + this.escape() + + this.backdrop(function () { + var transition = $.support.transition && that.$element.hasClass('fade') + + if (!that.$element.parent().length) { + that.$element.appendTo(document.body) //don't move modals dom position + } + + that.$element + .show() + + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + .attr('aria-hidden', false) + .focus() + + that.enforceFocus() + + transition ? + that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : + that.$element.trigger('shown') + + }) + } + + , hide: function (e) { + e && e.preventDefault() + + var that = this + + e = $.Event('hide') + + this.$element.trigger(e) + + if (!this.isShown || e.isDefaultPrevented()) return + + this.isShown = false + + $('body').removeClass('modal-open') + + this.escape() + + $(document).off('focusin.modal') + + this.$element + .removeClass('in') + .attr('aria-hidden', true) + + $.support.transition && this.$element.hasClass('fade') ? + this.hideWithTransition() : + this.hideModal() + } + + , enforceFocus: function () { + var that = this + $(document).on('focusin.modal', function (e) { + if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { + that.$element.focus() + } + }) + } + + , escape: function () { + var that = this + if (this.isShown && this.options.keyboard) { + this.$element.on('keyup.dismiss.modal', function ( e ) { + e.which == 27 && that.hide() + }) + } else if (!this.isShown) { + this.$element.off('keyup.dismiss.modal') + } + } + + , hideWithTransition: function () { + var that = this + , timeout = setTimeout(function () { + that.$element.off($.support.transition.end) + that.hideModal() + }, 500) + + this.$element.one($.support.transition.end, function () { + clearTimeout(timeout) + that.hideModal() + }) + } + + , hideModal: function (that) { + this.$element + .hide() + .trigger('hidden') + + this.backdrop() + } + + , removeBackdrop: function () { + this.$backdrop.remove() + this.$backdrop = null + } + + , backdrop: function (callback) { + var that = this + , animate = this.$element.hasClass('fade') ? 'fade' : '' + + if (this.isShown && this.options.backdrop) { + var doAnimate = $.support.transition && animate + + this.$backdrop = $('