diff --git a/README b/README index 48b6901..9e839c5 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ - Hackerspace Brussels + Hackerspace Brussels/Whitespace Ghent presents _ _ _ _ __ _ __ ___ (_) ___ ___| |_ _ __ __ _ _ __ ___ ___| | __ _ @@ -9,9 +9,38 @@ Imagine some very elaborate description on what this is, but I fail in finding -the right words right now. It is a very cool way to visualize people being -present in the same physical location. It scans the local network for mac +the right words right now. It is a very cool way to visualize any kind of data, +for example people being present in the same physical location. +Currently it comes with an example scanner that scans the local network for mac addresses and displays them in a very nice 3d HTML 5 canvas thing. Enough with -the words, look at the installation in hsbxl. +the words, look at the installation in hsbxl and whitespace: http://hackerspace.be/pam/ +http://0x20.be/pam + +Installation +============ + +* Copy all the files in a directory that is hosted by a webserver, e.g. apache +* Your webserver must naturally support php +* The php-sqlite3 extension must be installed + + +Configuration +============= + +* Edit the config.php to configure Pamela +* Make sure the configuration of where the database will be is a writable + directory, a database will be created there automatically using the name you + specified. + +Scanner details +=============== + +You can upload data to the webinterface by posting a comma separted list to the +upload.php page. This is done using application/x-www-form-urlencoded format, +with the key beying "data" and the value being a comma separated list of items. + +e.g. using wget: + +wget http://host/pamela/upload.php -O - --post-data data=comma,separated,list,of,items diff --git a/config.php.example b/config.php.example deleted file mode 100644 index 6eea047..0000000 --- a/config.php.example +++ /dev/null @@ -1,12 +0,0 @@ - 0) { +$data = data_get(); +if (count($data) > 0) { //multiply(); - echo('["'.implode('", "', $macs).'"]'); + echo('["'.implode('", "', $data).'"]'); } else { echo('[]'); } -macs_purge(); +data_purge(); diff --git a/fonts/AnjaEliane.ttf b/fonts/AnjaEliane.ttf deleted file mode 100644 index c8d6efc..0000000 Binary files a/fonts/AnjaEliane.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof35.ttf b/fonts/eurofurence/eurof35.ttf deleted file mode 100644 index ad174c3..0000000 Binary files a/fonts/eurofurence/eurof35.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof36.ttf b/fonts/eurofurence/eurof36.ttf deleted file mode 100644 index 9c56f48..0000000 Binary files a/fonts/eurofurence/eurof36.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof55.ttf b/fonts/eurofurence/eurof55.ttf deleted file mode 100644 index 94a9d79..0000000 Binary files a/fonts/eurofurence/eurof55.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof56.ttf b/fonts/eurofurence/eurof56.ttf deleted file mode 100644 index 7760acf..0000000 Binary files a/fonts/eurofurence/eurof56.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof75.ttf b/fonts/eurofurence/eurof75.ttf deleted file mode 100644 index ded8b46..0000000 Binary files a/fonts/eurofurence/eurof75.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof76.ttf b/fonts/eurofurence/eurof76.ttf deleted file mode 100644 index 99b9730..0000000 Binary files a/fonts/eurofurence/eurof76.ttf and /dev/null differ diff --git a/fonts/eurofurence/eurof_tt.txt b/fonts/eurofurence/eurof_tt.txt deleted file mode 100644 index 9c45e6c..0000000 --- a/fonts/eurofurence/eurof_tt.txt +++ /dev/null @@ -1,21 +0,0 @@ ------------------------------------------------------------------------- -The eurofurence typeface family by tobias b koehler (unci@tigerden.com) ------------------------------------------------------------------------- - -This is a family of geometric rounded sans serif fonts consisting of -three weights (light, medium, bold) in upright and italic styles, -originally designed for EuroFurence, the first European furry convention -1995 in Kaiser-Wilhelm-Koog. - -The character set includes Roman, Greek and Cyrillic characters. -File format is TrueType for PC (under Windows, Linux etc). - -These fonts are freeware and can be distributed as long as they are -together with this text file. I would appreciate it though if you could -contact me at unci@tigerden.com if you put them on a server. Free -samples from commercial users are always very welcome. :) - -For more information, please see the uncifonts WWW page at: -http://mercurio.iet.unipi.it/users/tobias/uncifonts.html - -Have fun! tobias b koehler, 2000-04-02 \ No newline at end of file diff --git a/img/whitespace-logo-square-transp-drop.png b/img/0x20.png similarity index 100% rename from img/whitespace-logo-square-transp-drop.png rename to img/0x20.png diff --git a/img/pamela-logo.png b/img/pamela-logo.png deleted file mode 100644 index 6b5d979..0000000 Binary files a/img/pamela-logo.png and /dev/null differ diff --git a/index.php b/index.php index d05e8a8..b0be8f6 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,23 @@ . +*/ + require_once("config.php"); ?> diff --git a/js/pamela-buttons.js b/js/pamela-buttons.js index eb43d66..95925bb 100644 --- a/js/pamela-buttons.js +++ b/js/pamela-buttons.js @@ -98,7 +98,6 @@ function DownloadScriptButton(x, y) { DownloadScriptButton.prototype.draw = function() { if (this.isHover) { - //context.fillStyle = 'rgb(192,192,192)'; context.fillStyle = config.buttonColor; context.font = "18pt sans-serif"; context.fillText("Download pamela scanner script", this.x, this.y - 10); diff --git a/js/pamela-nodes.js b/js/pamela-nodes.js index f304687..e207928 100644 --- a/js/pamela-nodes.js +++ b/js/pamela-nodes.js @@ -1,5 +1,5 @@ /* - Copyright 2009 Pieter Iserbyt + Copyright 2010 Pieter Iserbyt This file is part of Pamela. @@ -33,12 +33,10 @@ function ColorGenerator() { } ColorGenerator.prototype.generate = function() { - if (this.colorGeneratorValue > this.colors.length) + this.colorGeneratorValue += 1; + if (this.colorGeneratorValue >= this.colors.length) this.colorGeneratorValue = 0; - - // weirdo fix for chrome bug where the colors get - // garbage collected. I think. - var c = this.colors[this.colorGeneratorValue++]; + var c = this.colors[this.colorGeneratorValue]; return [c[0], c[1], c[2]]; }; @@ -52,10 +50,6 @@ function Node(name) { this.setMode("newNode"); var size = Math.min(width, height); - //this.color = [ - // Math.random() * 128, - // Math.random() * 128, - // Math.random() * 128]; this.color = colorGenerator.generate(); this.position = new Vector( (Math.random() * size) - (size / 2), @@ -97,19 +91,12 @@ Node.prototype.normal = { var scale = width * 3 / -this.projection.z; var alphaScale = 0.5 + this.alpha / 128; var invAlphaScale = 1 - alphaScale; - var col = - /* [ - Math.round(this.color[0]), - Math.round(this.color[1]), - Math.round(this.color[2]), - ]; */ - [ + var col = [ Math.round(128 * invAlphaScale + this.color[0] * alphaScale), Math.round(128 * invAlphaScale + this.color[1] * alphaScale), Math.round(128 * invAlphaScale + this.color[2] * alphaScale), ]; context.fillStyle = 'rgb(' + col[0] + ',' + col[1] + ',' + col[2] + ')'; - //context.globalAlpha = this.alpha / 255; context.beginPath(); context.arc(this.projection.x, this.projection.y, scale, 0, Math.PI * 2, false); context.fill(); diff --git a/js/pamela.js b/js/pamela.js index 909b91b..2f52767 100644 --- a/js/pamela.js +++ b/js/pamela.js @@ -1,5 +1,5 @@ /* - Copyright 2009 Pieter Iserbyt + Copyright 2010 Pieter Iserbyt This file is part of Pamela. @@ -193,7 +193,7 @@ Pamela.prototype.resize = function() { Pamela.prototype.updateEntries = function() { var self = this; - $.getJSON("macs.php", function(data) { + $.getJSON("data.php", function(data) { self.updateNodes(data); }); self.entriesTimer = setTimeout(function() { self.updateEntries(); }, 20000); diff --git a/lib/data.php b/lib/data.php new file mode 100644 index 0000000..b2ae1ab --- /dev/null +++ b/lib/data.php @@ -0,0 +1,70 @@ +. +*/ +require_once("lib/db.php"); + +function data_check_table() { + static $table_exists = FALSE; + + // already checked? skip... + if ($table_exists == TRUE) { + return; + } + + // get db handle + $db = get_db(); + + // already in db? skip and remember... + $q = $db->query("select name from sqlite_master where type='table' and name='data'"); + if ($q->fetchArray()) { + $table_exists = TRUE; + return; + } + + // create the table and remember... + $table_exists = $db->exec("create table data (data text unique on conflict replace, committime integer)"); +} + +function data_get() { + $results = array(); + data_check_table(); + $db = get_db(); + $q = $db->query("select data from data where committime > strftime('%s','now') - ".DATA_TTL); + if (!$q) return $results; + while($row = $q->fetchArray(SQLITE3_ASSOC)) { + $results[] = $row['data']; + } + return $results; +} + +function data_add($data) { + $db = get_db(); + data_check_table(); + $data = $db->escapeString($data); + #echo "insert or replace into data values (\"$data\", strftime('%s','now'))\n"; + $result = $db->exec("insert or replace into data values (\"$data\", strftime('%s','now'))"); + if (!$result) + echo "ERROR: ".$db->lastErrorMsg()."\n"; +} + +function data_purge() { + $db = get_db(); + data_check_table(); + return $db->exec("delete from data where committime <= strftime('%s','now') - ".DATA_TTL); +} diff --git a/lib/db.php b/lib/db.php index b094324..2cd2744 100644 --- a/lib/db.php +++ b/lib/db.php @@ -1,4 +1,22 @@ . +*/ require_once("config.php"); function get_db() { diff --git a/lib/macs.php b/lib/macs.php deleted file mode 100644 index 26f9ad8..0000000 --- a/lib/macs.php +++ /dev/null @@ -1,24 +0,0 @@ -query("select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL); - if (!$q) return $results; - while($row = $q->fetch_array(SQLITE_ASSOC)) { - $results[] = $row['mac']; - } - return $results; -} - -function macs_add($mac) { - $db = get_db(); - $mac = $db->escape_string($mac); - return $db->exec("insert or replace into macs values (\"$mac\", strftime('%s','now'))"); -} - -function macs_purge() { - $db = get_db(); - return $db->exec("delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL); -} diff --git a/pamela.css b/pamela.css deleted file mode 100644 index e0d7672..0000000 --- a/pamela.css +++ /dev/null @@ -1,23 +0,0 @@ -@font-face { - font-family: AnjaEliane; - src: url('http://localhost/sb/pamela/fonts/AnjaEliane.ttf'); -} - -@font-face { - font-family: Eurofurence; - src: url('http://localhost/sb/pamela/fonts/eurofurence/eurof35.ttf'); -} - -body { - font-family: Eurofurence; -} - -h1, h2, h3, h4, h5, h6 { - font-family: AnjaEliane, sans-serif; - font-weight: normal; -} - -p { - font-family: Eurofurence; - font-size: 16pt; -} diff --git a/scanner/pamela-scanner.sh b/scanner/pamela-scanner.sh index d26e674..e6dfd4e 100755 --- a/scanner/pamela-scanner.sh +++ b/scanner/pamela-scanner.sh @@ -45,11 +45,10 @@ function usage { -p Http-auth password. Defaults to [$PASSWORD]. -h Shows help -Pamela is an arp-scanner, it uploads the mac addresses in your local lan on a -webserver where you get a visual representation of the mac addresses present. -Multiple people on multiple lans can run pamela together against the same -server, where all results are agregated. In short, pamela gives you an overview -of how big the shared network is." +This pamela scanner is an arp-scanner that uploads mac addresses in your local +lan on a webserver where you get a visual representation of those mac addresses +present. Multiple people on multiple lans can run this or any other scanner +together against the same web server, where all results will be agregated." } function check_if_root { @@ -109,22 +108,22 @@ function parse_params { function scan_and_upload { echo $(date)" scanning..." - NETMASK="$(ip -4 addr show "$IF" | egrep -o "brd [0-9\.]+" | egrep -o "[0-9\.]+")" - MACS="" - NUM_MACS=0 + DATA="" + NUM_DATA=0 for M in $(arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print $2 }' | grep :.*: | sort | uniq) do - [ -n "$MACS" ] && MACS="$MACS,$M" || MACS="$M"; - let "NUM_MACS=NUM_MACS+1" + [ -n "$DATA" ] && DATA="$DATA,$M" || DATA="$M"; + let "NUM_DATA=NUM_DATA+1" done - POST="sn=$NETMASK&macs=$MACS" - RESULT=$(wget "$OUT" -O - --quiet --post-data "$POST" --user "$USER" --password "$PASSWORD" || echo "wget error: $?") + POST="data=$DATA" + echo wget "$OUT" -O - --quiet --post-data "$POST" --user "$USER" --password "$PASSWORD" || echo "wget error: $?" + RESULT=$(wget "$OUT" -O - --post-data "$POST" --user "$USER" --password "$PASSWORD") if [ -n "$RESULT" ] then echo Error uploading results: echo "$RESULT" fi - echo $(date)" Uploaded $NUM_MACS mac addresses..." + echo $(date)" Uploaded $NUM_DATA mac addresses..." } parse_params $@ diff --git a/upload.php b/upload.php index 29dcaa7..ca8e381 100644 --- a/upload.php +++ b/upload.php @@ -1,6 +1,6 @@ macs = getPost("macs"); + $this->data = getPost("data"); } - private function parseAndValidate() { - if ($this->macs == NULL) { - echoln("Missing macs param"); + private function validate() { + if ($this->data == NULL) { + echoln("Missing data param"); return false; } - $mcs = explode(',', $this->macs); - foreach($mcs as $mac) { - if (preg_match("/^(([\dABCDEF]){2}:){5}([\dABCDEF]){2}$/i", $mac) == 1) - continue; - echoln("mac $mac is not in the right format"); - return false; - } return true; } - private function writeMacs() { - $mcs = explode(',', $this->macs); - foreach($mcs as $mac) { - macs_add($mac); + private function writeData() { + $datas = explode(',', $this->data); + foreach($datas as $data) { + data_add($data); } } public function run() { - $this->parseAndValidate(); - $this->writeMacs(); + if ($this->validate()) + $this->writeData(); } }