diff --git a/.gitignore b/.gitignore index 588ef51..025ab81 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ design db config.php scanner/pamela.log +mac_log.csv +mac_log.csv.complete diff --git a/admin.php b/admin.php new file mode 100755 index 0000000..e0ca8ed --- /dev/null +++ b/admin.php @@ -0,0 +1,31 @@ + + + + + + + + +
+ + +
+ + diff --git a/associate.php b/associate.php new file mode 100755 index 0000000..5dfc83e --- /dev/null +++ b/associate.php @@ -0,0 +1,77 @@ + 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'); +?> + + + + +
+

Register Your Device

+
+
+

Your computer or mobile device's MAC address can be found under your network info!

+ + + +
+ +
+ +
+
+
+ + + + + diff --git a/header-inc.php b/header-inc.php new file mode 100755 index 0000000..41aadbe --- /dev/null +++ b/header-inc.php @@ -0,0 +1,39 @@ + + + + + + + + + + + +onLoad="pageLoad()"> + +
diff --git a/index.php b/index.php index b0be8f6..fe675db 100644 --- a/index.php +++ b/index.php @@ -1,45 +1,30 @@ -body); // get rid of linebreaks - 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. +$decode = json_decode($result); +$decode = preg_replace("/^([0-9a-f]{2}([:]|$)){6}$/i",'{$0}',$decode); +sort($decode,SORT_STRING | SORT_FLAG_CASE); - You should have received a copy of the GNU General Public License - along with Pamela. If not, see . -*/ +$array = preg_grep("/^(?!\.)/",$decode); -require_once("config.php"); -?> - - Pamela - - - - - - - - - - - +echo "

Who's here right now?

"; +echo ""; + +?> +
+ diff --git a/README b/pamela/README similarity index 100% rename from README rename to pamela/README diff --git a/config.example.php b/pamela/config.example.php similarity index 100% rename from config.example.php rename to pamela/config.example.php diff --git a/data.php b/pamela/data.php similarity index 100% rename from data.php rename to pamela/data.php diff --git a/img/0x20.png b/pamela/img/0x20.png similarity index 100% rename from img/0x20.png rename to pamela/img/0x20.png diff --git a/img/ccc.png b/pamela/img/ccc.png similarity index 100% rename from img/ccc.png rename to pamela/img/ccc.png diff --git a/img/dl-col.png b/pamela/img/dl-col.png similarity index 100% rename from img/dl-col.png rename to pamela/img/dl-col.png diff --git a/img/dl.png b/pamela/img/dl.png similarity index 100% rename from img/dl.png rename to pamela/img/dl.png diff --git a/img/max-col.png b/pamela/img/max-col.png similarity index 100% rename from img/max-col.png rename to pamela/img/max-col.png diff --git a/img/max.png b/pamela/img/max.png similarity index 100% rename from img/max.png rename to pamela/img/max.png diff --git a/img/min-col.png b/pamela/img/min-col.png similarity index 100% rename from img/min-col.png rename to pamela/img/min-col.png diff --git a/img/min.png b/pamela/img/min.png similarity index 100% rename from img/min.png rename to pamela/img/min.png diff --git a/img/norbert-8bit.png b/pamela/img/norbert-8bit.png similarity index 100% rename from img/norbert-8bit.png rename to pamela/img/norbert-8bit.png diff --git a/img/norbert.png b/pamela/img/norbert.png similarity index 100% rename from img/norbert.png rename to pamela/img/norbert.png diff --git a/pamela/index.php b/pamela/index.php new file mode 100755 index 0000000..b0be8f6 --- /dev/null +++ b/pamela/index.php @@ -0,0 +1,45 @@ +. +*/ + +require_once("config.php"); +?> + + Pamela + + + + + + + + + + + + diff --git a/js/jquery-1.3.2.js b/pamela/js/jquery-1.3.2.js similarity index 100% rename from js/jquery-1.3.2.js rename to pamela/js/jquery-1.3.2.js diff --git a/js/pamela-buttons.js b/pamela/js/pamela-buttons.js similarity index 100% rename from js/pamela-buttons.js rename to pamela/js/pamela-buttons.js diff --git a/js/pamela-conf.php b/pamela/js/pamela-conf.php similarity index 100% rename from js/pamela-conf.php rename to pamela/js/pamela-conf.php diff --git a/js/pamela-matrices.js b/pamela/js/pamela-matrices.js similarity index 100% rename from js/pamela-matrices.js rename to pamela/js/pamela-matrices.js diff --git a/js/pamela-nodes.js b/pamela/js/pamela-nodes.js similarity index 100% rename from js/pamela-nodes.js rename to pamela/js/pamela-nodes.js diff --git a/js/pamela.js b/pamela/js/pamela.js similarity index 100% rename from js/pamela.js rename to pamela/js/pamela.js diff --git a/lib/data.php b/pamela/lib/data.php similarity index 100% rename from lib/data.php rename to pamela/lib/data.php diff --git a/lib/db.php b/pamela/lib/db.php similarity index 100% rename from lib/db.php rename to pamela/lib/db.php diff --git a/lib/util.php b/pamela/lib/util.php similarity index 100% rename from lib/util.php rename to pamela/lib/util.php diff --git a/license.txt b/pamela/license.txt similarity index 100% rename from license.txt rename to pamela/license.txt diff --git a/scanner/pamela-scanner.sh b/pamela/scanner/pamela-scanner.sh similarity index 82% rename from scanner/pamela-scanner.sh rename to pamela/scanner/pamela-scanner.sh index ba069d0..f3e0e65 100755 --- a/scanner/pamela-scanner.sh +++ b/pamela/scanner/pamela-scanner.sh @@ -26,11 +26,11 @@ PAM_CRON="/etc/cron.d/pamela" PAM_SCRIPT="${PAM_DIR}/$(basename $0)" REGISTER='' SIMULATE='' -IF='eth0' -OUT='http://yourserver.com/pamela/upload.php' +IF='p2p1' +OUT='http://yourserver.com/upload.php' USER='' PASSWORD='' -TRANSLATE='' +TRANSLATE='/var/www/html/mac_log.csv' POST='' TIMEOUT=200 @@ -136,35 +136,45 @@ function translate { then return 0 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) - wget --timeout="${TIMEOUT}" --no-check-certificate --quiet -O "${TRANSLATE}" "${TRANSLATE_URL}" + # clean old translations + rm $TRANSLATE.complete - POST=$(echo ${POST} | awk -v names="${TRANSLATE}" 'BEGIN { + # Then we fall back to names obtained via zeroconf (aka avahi, aka bonjour) + #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" FS="," while ((getline nl < names) > 0) { split(nl, n); nms[n[1]] = n[2] } + close(names) RS="," first=1 while ((getline i)> 0) { sub(/\n$/,"",i) - #print "input:", i, "translates to", (i in nms?nms[i]:i) + # if (i in nms){ print "input:", i, "translates to", nms[i] } if (!first) printf(",") printf (i in nms?nms[i]:i) first=0 } - }') - rm ${TRANSLATE} + }') } function upload { @@ -191,3 +201,5 @@ scan translate upload +git commit mac_log.csv -m "Save updates user database" + diff --git a/upload.php b/pamela/upload.php similarity index 100% rename from upload.php rename to pamela/upload.php diff --git a/static/images/logo.png b/static/images/logo.png new file mode 100644 index 0000000..e69de29 diff --git a/style.css b/style.css new file mode 100644 index 0000000..e69de29