removal of unneeded files, fixes of some SQLite3 bugs, added README/doc

This commit is contained in:
sandb 2010-11-14 07:39:36 +01:00
parent c28ce28aab
commit 755a608cd7
23 changed files with 182 additions and 148 deletions

37
README
View File

@ -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

View File

@ -1,12 +0,0 @@
<?php
// Number of seconds a mac address file is valid. If it's older it will be removed.
define("MACFILE_TTL", "3600");
// Where the db is located for the sqlite db. The file does not have to exist.
// The directory does need to exist though, and the directory must be writable.
define("SQLITE_DB", "/home/sandbender/www/pamela/db/pamela.sql");
// sql create statement for mac table
define("CREATE_MAC_TABLE_SQL", "create table macs (mac text unique on conflict replace, committime integer);");
define("CREATE_KNOWN_MAC_TABLE_SQL", "create table knownmacs (userid integer, mac text, name text, primary key (mac, userid));");

View File

@ -1,6 +1,6 @@
<?php
/*
Copyright 2009 Pieter Iserbyt
Copyright 2010 Pieter Iserbyt
This file is part of Pamela.
@ -24,24 +24,24 @@ header("Cache-Control: no-cache");
header("Pragma: no-cache");
require_once("config.php");
require_once("lib/macs.php");
require_once("lib/data.php");
// for debug purposes, increases the numbers of macs artificially
// for debug purposes, increases the numbers of data artificially
function multiply() {
global $macs;
$c = count($macs);
global $data;
$c = count($data);
for ($j = 0; $j < $c; $j++) {
for ($i = 0; $i <10; $i++) {
$macs[] = $macs[$j].$i;
$data[] = $data[$j].$i;
}
}
}
$macs = macs_get();
if (count($macs) > 0) {
$data = data_get();
if (count($data) > 0) {
//multiply();
echo('["'.implode('", "', $macs).'"]');
echo('["'.implode('", "', $data).'"]');
} else {
echo('[]');
}
macs_purge();
data_purge();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,4 +1,23 @@
<?php
/*
Copyright 2010 Pieter Iserbyt
This file is part of Pamela.
Pamela is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Pamela is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
*/
require_once("config.php");
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>

View File

@ -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);

View File

@ -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();

View File

@ -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);

70
lib/data.php Normal file
View File

@ -0,0 +1,70 @@
<?php
/*
Copyright 2010 Pieter Iserbyt
This file is part of Pamela.
Pamela is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Pamela is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
*/
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);
}

View File

@ -1,4 +1,22 @@
<?php
/*
Copyright 2010 Pieter Iserbyt
This file is part of Pamela.
Pamela is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Pamela is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
*/
require_once("config.php");
function get_db() {

View File

@ -1,24 +0,0 @@
<?php
require_once("lib/db.php");
function macs_get() {
$results = array();
$db = get_db();
$q = $db->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);
}

View File

@ -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;
}

View File

@ -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 $@

View File

@ -1,6 +1,6 @@
<?php
/*
Copyright 2009 Pieter Iserbyt
Copyright 2010 Pieter Iserbyt
This file is part of Pamela.
@ -20,42 +20,35 @@
header("Content-type: text/plain");
require_once("lib/util.php");
require_once("lib/macs.php");
require_once("lib/data.php");
class Upload {
private $macs;
private $data;
function __construct() {
$this->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();
}
}