Compare commits

..

No commits in common. "master" and "1.2" have entirely different histories.
master ... 1.2

33 changed files with 56 additions and 258 deletions

2
.gitignore vendored
View File

@ -3,5 +3,3 @@ design
db db
config.php config.php
scanner/pamela.log scanner/pamela.log
mac_log.csv
mac_log.csv.complete

4
README
View File

@ -1,7 +1,3 @@
HeatSync Labs / Cohoots Phoenix branch
https://github.com/zyphlar/pamela
-------
Hackerspace Brussels/Whitespace Ghent Hackerspace Brussels/Whitespace Ghent
presents presents
_ _ _ _ _ _

View File

@ -1,31 +0,0 @@
<?php
if ($_POST) {
$text = preg_replace("/\s{2}/i","\n",$_POST['text']);
file_put_contents("mac_log.csv",$text);
header ("Location: ".$_SERVER['PHP_SELF']."?saved=true");
exit;
}
$text = htmlspecialchars(file_get_contents("mac_log.csv"));
if($_GET['saved'] == "true") {
$message = "Saved successfully.";
}
?><html>
<head>
<style type="text/css">
textarea { height: 600px; width: 400px; }
</style>
</head>
<body>
<span class="message">
<?php echo $message; ?>
</span>
<form method="POST">
<textarea name="text"><?php echo $text; ?></textarea>
<input type="submit" value="Save">
</form>
</body>
</html>

View File

@ -1,77 +0,0 @@
<?php
$message = "";
if(isset($_POST['submit'])) {
$mac = csv_filter($_POST['macaddress']);
$name = csv_filter($_POST['name']);
if($mac != "" && $name != null) {
if(is_mac($mac)) {
file_put_contents("mac_log.csv","$mac,$name\n",FILE_APPEND);
$message = "Registered, thanks! It might take a few minutes for your name to show up.";
}
else {
$message = "The MAC address doesn't look right. MAC addresses look like this: 00:1a:2b:3c:4d:5e";
}
}
else {
$message = "Please enter a MAC address and name.";
}
}
function csv_filter($value) {
return preg_replace('/[^a-z0-9: {}]/i','',$value);
}
function is_mac($mac) {
if(preg_match('/^([0-9a-f]{2}([:-]|$)){6}$/i',$mac) > 0){
return true;}
else { return false; }
}
$arp_found = false;
function arp_lookup($ip) {
global $arp_found;
$arp = shell_exec("/usr/sbin/arp -a | grep $ip");
preg_match('/at ([0-9a-f]{2}[: ]){6}/i',$arp,$matches);
if(sizeof($matches) > 0) {
$mac = split(" ",$matches[0]);
$arp_found = true;
return $mac[1];
}
else {
$arp_found = false;
return "";
}
}
include('header-inc.php');
?>
<span class="message">
<?php echo $message; ?>
</span>
<div id="content">
<h2>Register Your Device</h2>
<div class="caption">
<form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
<h3>Your computer or mobile device's MAC address can be found under your network info!</h3>
<table>
<tr><td><label for="name">Your Name:</label></td><td><input type="text" id="name" name="name" /></td></tr>
<tr><td><label for="macaddress">MAC Address:</label></td><td><input type="text" id="macaddress" name="macaddress" value="<?php echo arp_lookup($_SERVER['REMOTE_ADDR']); ?>" />
<span id="autodetect"><?php if($arp_found) { echo "(Autodetected your MAC from IP address ".$_SERVER['REMOTE_ADDR'].")"; } ?></span>
</td></tr>
</table>
<input type="submit" id="submit" name="submit" value="Register" />
</form>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,39 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<?php if(isset($auto_reload)) { ?>
<script type="text/javascript">
function reload() {
window.location.reload()
}
function pageLoad() {
setInterval ( "reload()", 30000 );
}
</script>
<?php } ?>
<style type="text/css">
#autodetect { display: block; color: #666; }
.macaddr { color: #666; }
</style>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css" />
</head>
<body <?php if(isset($auto_reload)){ ?>onLoad="pageLoad()"<?php } ?>>
<div id="header">
<div id="header_middle">
<img src="/static/images/logo.png" />
<div id="header_buttons">
<h2>Local Network</h2>
<p>See if there are people at the space!<br/>
If the feed is broken, please contact <a href="#">someone</a>.</p>
<p>Nobody here? Check the <a href="#">Website</a>.</p>
</div>
</div>
<div id="header_menu">
<a href="/">See Who's Here</a>
<a href="/associate.php">Register your device!</a>
</div>
</div>
<div id="content">

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 549 B

After

Width:  |  Height:  |  Size: 549 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 673 B

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,38 +1,45 @@
<?php <?php
$auto_reload = true; /*
include('header-inc.php'); Copyright 2010 Pieter Iserbyt
This file is part of Pamela.
$result = http_parse_message(http_get("http://localhost/pamela/data.php")); Pamela is free software: you can redistribute it and/or modify
$result = preg_replace("/[\r|\n]/","",$result->body); // get rid of linebreaks 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.
$decode = json_decode($result); Pamela is distributed in the hope that it will be useful,
$decode = preg_replace("/^([0-9a-f]{2}([:]|$)){6}$/i",'{$0}',$decode); but WITHOUT ANY WARRANTY; without even the implied warranty of
sort($decode,SORT_STRING | SORT_FLAG_CASE); MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
$array = preg_grep("/^(?!\.)/",$decode); You should have received a copy of the GNU General Public License
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
*/
echo "<h2>Who's here right now?</h2>"; require_once("config.php");
echo "<ul>"; ?><html xmlns="http://www.w3.org/1999/xhtml">
foreach($array as $entry) { <head>
if(substr($entry,0,1) == "{") { <title>Pamela</title>
if($_GET['showmacs'] == "1") { <script src="js/jquery-1.3.2.js" type="text/javascript"></script>
echo "<li class='macaddr'>".$entry."</li>"; <script src="js/pamela-conf.php" type="text/javascript"></script>
} <script src="js/pamela-buttons.js" type="text/javascript"></script>
} <script src="js/pamela-nodes.js" type="text/javascript"></script>
else{ <script src="js/pamela-matrices.js" type="text/javascript"></script>
echo "<li>".$entry."</li>"; <script src="js/pamela.js" type="text/javascript"></script>
} <style type="text/css">
} * {
if($_GET['showmacs'] == "1") { margin:0;
echo "<li>&nbsp;<br/><a href=\"?showmacs=0\">Hide people who haven't registered yet</a>"; padding:0;
} }
else {
echo "<li>&nbsp;<br/><a href=\"?showmacs=1\">Show people who haven't registered yet</a>"; body {
} background-color: <?php echo PAM_BGCOLOR; ?>;
echo "</ul>"; }
</style>
?> </head>
</div> <body>
</body> <canvas id="pamela"></canvas>
</body>
</html> </html>

View File

@ -1,45 +0,0 @@
<?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>
<title>Pamela</title>
<script src="js/jquery-1.3.2.js" type="text/javascript"></script>
<script src="js/pamela-conf.php" type="text/javascript"></script>
<script src="js/pamela-buttons.js" type="text/javascript"></script>
<script src="js/pamela-nodes.js" type="text/javascript"></script>
<script src="js/pamela-matrices.js" type="text/javascript"></script>
<script src="js/pamela.js" type="text/javascript"></script>
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background-color: <?php echo PAM_BGCOLOR; ?>;
}
</style>
</head>
<body>
<canvas id="pamela"></canvas>
</body>
</html>

View File

@ -26,13 +26,12 @@ PAM_CRON="/etc/cron.d/pamela"
PAM_SCRIPT="${PAM_DIR}/$(basename $0)" PAM_SCRIPT="${PAM_DIR}/$(basename $0)"
REGISTER='' REGISTER=''
SIMULATE='' SIMULATE=''
IF='p2p1' IF='eth0'
OUT='http://yourserver.com/upload.php' OUT='http://yourserver.com/pamela/upload.php'
USER='' USER=''
PASSWORD='' PASSWORD=''
TRANSLATE='/var/www/html/mac_log.csv' TRANSLATE=''
POST='' POST=''
TIMEOUT=200
function usage { function usage {
echo "Usage: pamela-scanner [OPTIONS] echo "Usage: pamela-scanner [OPTIONS]
@ -74,7 +73,7 @@ function register {
check_if_root check_if_root
check_if_arpscan_installed check_if_arpscan_installed
echo "Registering pamela in cron: ${PAM_CRON}" echo "Registering pamela in cron: ${PAM_CRON}"
echo "*/2 * * * * root [ -x \"${PAM_SCRIPT}\" ] && \"${PAM_SCRIPT}\" -i \"${IF}\" -o \"${OUT}\" -u \"${USER}\" -p \"${PASSWORD}\" -t \"${TRANSLATE}\" | logger -t pamela" > "${PAM_CRON}" echo "*/2 * * * * [ -x \"${PAM_SCRIPT}\" ] && \"${PAM_SCRIPT}\" -i \"${IF}\" -o \"${OUT}\" -u \"${USER}\" -p \"${PASSWORD}\" -t \"${TRANSLATE}\" | logger -t pamela" > "${PAM_CRON}"
echo "Depending on your version of crond, you might have to restart the cron daemon for the changes to take effect" echo "Depending on your version of crond, you might have to restart the cron daemon for the changes to take effect"
} }
@ -136,53 +135,43 @@ function translate {
then then
return 0 return 0
fi fi
# translate denotes a url
# save the output of the url to a file and use it as a file
TRANSLATE_URL=${TRANSLATE}
TRANSLATE=$(mktemp)
# clean old translations wget --no-check-certificate --quiet -O "${TRANSLATE}" "${TRANSLATE_URL}"
rm $TRANSLATE.complete
# Then we fall back to names obtained via zeroconf (aka avahi, aka bonjour) POST=$(echo ${POST} | awk -v names="${TRANSLATE}" 'BEGIN {
#avahi-browse -a -t|grep :.*:.*:.*:|sed -e 's/.*IPv. \(.*\) \[\(.*\)].*/\2,\1[\2]/g' > $TRANSLATE.bon
# Finally we fall back to the name from arp-scan (maker of the network chipset)
# Yes I know we already ran arp-scan once...I'm too lazy to do it right
# And yes I'm using regex instead of learning how awk works.
#arp-scan -I eth0 -R --localnet|sed -e 's/\(.*\)\t\(.*\)\t\(.*\)/\2,\3[\2]/g'|grep :.*:.*:> $TRANSLATE.arp
# Combine names from 3 sources to one
# Note that the code below uses the last name to appear in the file
# So order them accordingly
#cat $TRANSLATE.bon $TRANSLATE.arp
cat $TRANSLATE >> $TRANSLATE.complete
POST=$(echo ${POST} | awk -v names="${TRANSLATE}.complete" 'BEGIN {
RS="\n" RS="\n"
FS="," FS=","
while ((getline nl < names) > 0) { while ((getline nl < names) > 0) {
split(nl, n); split(nl, n);
nms[n[1]] = n[2] nms[n[2]] = n[1]
} }
close(names) close(names)
RS="," RS=","
first=1 first=1
while ((getline i)> 0) { while ((getline i)> 0) {
sub(/\n$/,"",i) sub(/\n$/,"",i)
# if (i in nms){ print "input:", i, "translates to", nms[i] } #print "input:", i, "translates to", (i in nms?nms[i]:i)
if (!first) if (!first)
printf(",") printf(",")
printf (i in nms?nms[i]:i) printf (i in nms?nms[i]:i)
first=0 first=0
} }
}') }')
rm ${TRANSLATE}
} }
function upload { function upload {
if [ -z "${SIMULATE}" ] if [ -z "${SIMULATE}" ]
then then
RESULT=$(wget "${OUT}" --timeout="${TIMEOUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}") RESULT=$(wget "${OUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}")
else else
echo Not executing: [wget "${OUT}" --timeout="${TIMEOUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}"] echo Not executing: [wget "${OUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}"]
RESULT= RESULT=
fi fi

View File

View File