downloading of script, script updated, support for distrib upload finalized (i think)
This commit is contained in:
parent
6366bfdef4
commit
b77e986a16
BIN
img/ccc.png
BIN
img/ccc.png
Binary file not shown.
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
BIN
img/dl-col.png
Normal file
BIN
img/dl-col.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
img/dl.png
Normal file
BIN
img/dl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -80,6 +80,37 @@ FullScreenButton.prototype.execute = function() {
|
|||
//TODO: do somth
|
||||
};
|
||||
|
||||
// Class DownloadScriptButton
|
||||
|
||||
jQuery.extend(DownloadScriptButton.prototype, IFaceButton.prototype);
|
||||
function DownloadScriptButton(x, y) {
|
||||
|
||||
this.width = 64;
|
||||
this.height = 64;
|
||||
|
||||
this.isHover = false;
|
||||
|
||||
this.dlCol = new Image();
|
||||
this.dlCol.src = "img/dl-col.png";
|
||||
this.dl = new Image();
|
||||
this.dl.src = "img/dl.png";
|
||||
};
|
||||
|
||||
DownloadScriptButton.prototype.draw = function() {
|
||||
if (this.isHover) {
|
||||
context.fillStyle = 'rgb(192,192,192)';
|
||||
context.font = "18pt sans-serif";
|
||||
context.fillText("Download pamela scanner script", this.x, this.y - 10);
|
||||
context.drawImage(this.dlCol, this.x, this.y);
|
||||
} else {
|
||||
context.drawImage(this.dl, this.x, this.y);
|
||||
}
|
||||
};
|
||||
|
||||
DownloadScriptButton.prototype.execute = function() {
|
||||
location.href = 'pamela-scanner.sh';
|
||||
};
|
||||
|
||||
// Class IFace buttons
|
||||
function IFaceButtons() {
|
||||
this.buttons = [];
|
||||
|
@ -91,11 +122,11 @@ IFaceButtons.prototype.add = function(button) {
|
|||
};
|
||||
|
||||
IFaceButtons.prototype.reposition = function() {
|
||||
var x = width - 64;
|
||||
var x = 20;
|
||||
var y = height - 64;
|
||||
for (var i = 0; i < this.buttons.length; i++) {
|
||||
this.buttons[i].moveTo(x, y);
|
||||
x -= 64;
|
||||
x += 64;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -104,3 +135,17 @@ IFaceButtons.prototype.draw = function() {
|
|||
this.buttons[i].draw();
|
||||
};
|
||||
|
||||
IFaceButtons.prototype.mousemove = function(event) {
|
||||
for (var i =0; i < this.buttons.length; i++) {
|
||||
var b = this.buttons[i];
|
||||
b.isHover = b.isHovered(event.offsetX, event.offsetY);
|
||||
}
|
||||
};
|
||||
|
||||
IFaceButtons.prototype.mouseclick = function(event) {
|
||||
for (var i =0; i < this.buttons.length; i++) {
|
||||
var b = this.buttons[i];
|
||||
if (b.isHovered(event.offsetX, event.offsetY))
|
||||
b.execute();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -156,7 +156,7 @@ NorbertNode.prototype.draw = function() {
|
|||
s *= 2;
|
||||
//var x = Math.floor(this.projection.x - (186 / s));
|
||||
//var y = Math.floor(this.projection.y - (50 / s));
|
||||
var x = Math.floor(this.projection.x - (250 / s));
|
||||
var x = Math.floor(this.projection.x - (192 / s));
|
||||
var y = Math.floor(this.projection.y - (180 / s));
|
||||
context.drawImage(this.norbert, x, y);
|
||||
};
|
||||
|
|
17
js/pamela.js
17
js/pamela.js
|
@ -36,8 +36,8 @@ function Pamela(canvas) {
|
|||
};
|
||||
|
||||
this.buttons = new IFaceButtons();
|
||||
this.fullScreenButton = new FullScreenButton();
|
||||
this.buttons.add(this.fullScreenButton);
|
||||
this.downloadScriptButton = new DownloadScriptButton();
|
||||
this.buttons.add(this.downloadScriptButton);
|
||||
this.resize();
|
||||
|
||||
this.m = new Matrix();
|
||||
|
@ -114,20 +114,13 @@ Pamela.prototype.start = function() {
|
|||
};
|
||||
|
||||
Pamela.prototype.mousemove = function(event) {
|
||||
this.fullScreenButton.isHover = this.fullScreenButton.isHovered(event.offsetX, event.offsetY);
|
||||
this.buttons.mousemove(event);
|
||||
this.mouse.x = event.offsetX;
|
||||
this.mouse.y = event.offsetY;
|
||||
};
|
||||
|
||||
Pamela.prototype.mouseclick = function(event) {
|
||||
if (this.fullScreenButton.isHovered(event.offsetX, event.offsetY))
|
||||
this.fullScreenButton.execute();
|
||||
};
|
||||
|
||||
Pamela.prototype.mousein = function(event) {
|
||||
};
|
||||
|
||||
Pamela.prototype.mouseout = function(event) {
|
||||
this.buttons.mouseclick(event);
|
||||
};
|
||||
|
||||
Pamela.prototype.fire = function() {
|
||||
|
@ -199,7 +192,7 @@ Pamela.prototype.resize = function() {
|
|||
|
||||
Pamela.prototype.updateEntries = function() {
|
||||
var self = this;
|
||||
$.getJSON("js/input.php", function(data) {
|
||||
$.getJSON("macs.php", function(data) {
|
||||
self.updateNodes(data);
|
||||
});
|
||||
self.entriesTimer = setTimeout(function() { self.updateEntries(); }, 60000);
|
||||
|
|
9
macs.php
9
macs.php
|
@ -38,13 +38,13 @@ class Macs {
|
|||
|
||||
private function readFile($filename) {
|
||||
$mcs = file_get_contents($filename);
|
||||
$this->macs = array_merge($this->macs, explode('|', $mcs));
|
||||
$this->macs = array_merge($this->macs, explode(',', $mcs));
|
||||
}
|
||||
|
||||
private function readFiles($directory) {
|
||||
$macFiles = scandir($directory);
|
||||
foreach ($macFiles as $macFile) {
|
||||
if (preg_match("/\.macs$/", $macFile) != 1)
|
||||
if (preg_match("/.+\.macs$/", $macFile) != 1)
|
||||
continue;
|
||||
|
||||
$filename = "$directory/$macFile";
|
||||
|
@ -64,6 +64,11 @@ class Macs {
|
|||
}
|
||||
|
||||
private function createJson() {
|
||||
if (count($this->macs) < 1) {
|
||||
echo '[]';
|
||||
return;
|
||||
}
|
||||
|
||||
echo '["';
|
||||
echo implode('", "', $this->macs);
|
||||
echo '"]';
|
||||
|
|
|
@ -21,39 +21,66 @@
|
|||
|
||||
LICENSE
|
||||
|
||||
IF='eth0'
|
||||
OUT='js/input.php'
|
||||
function usage {
|
||||
|
||||
echo 'Usage: pamela-scanner [OPTIONS]
|
||||
|
||||
-i INTERFACE Interface to arp-scan
|
||||
-o URL The url of the pamela upload script (including /upload.php)
|
||||
-s TIME The time to sleep between scans in seconds.
|
||||
-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.'
|
||||
exit 1
|
||||
|
||||
}
|
||||
|
||||
IF='wlan0'
|
||||
OUT='http://localhost/sb/pamela/upload.php'
|
||||
SLEEP='60'
|
||||
|
||||
TEMP=$(getopt -o i:o:s:-n "pamela arp scanner" -- "$@")
|
||||
TEMP=$(getopt -o 'hi:o:s:-n' "pamela arp scanner" -- "$@")
|
||||
if [ $? != 0 ] ; then echo "Could not parse parameters..." >&2 ; exit 1 ; fi
|
||||
eval set "$TEMP" --
|
||||
eval set "$TEMP"
|
||||
while true
|
||||
do
|
||||
shift;
|
||||
[ -z "$1" ] && break;
|
||||
case "$1" in
|
||||
-i) IF="$2"; shift;;
|
||||
-o) OUT="$2"; shift;;
|
||||
-s) SLEEP="$2"; shift;;
|
||||
--) break;;
|
||||
-h|'-?') usage; break;;
|
||||
*) echo "Unknown param: [$1]"; usage; exit 1;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
sudo -n true || { echo "Must be root to run pamela-scanner"; exit 1; }
|
||||
|
||||
if [ -z "$(sudo which arp-scan)" ]
|
||||
then
|
||||
echo "Could not find arp-scan, which is required for pamela to scan the mac addresses"
|
||||
fi
|
||||
|
||||
while true
|
||||
do
|
||||
echo $(date)" scanning..."
|
||||
O="";
|
||||
O="$O"'<?php '
|
||||
O="$O"' header("Content-type: application/pdf"); '
|
||||
O="$O"' header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); '
|
||||
O="$O"' header("Cache-Control: no-cache"); '
|
||||
O="$O"' header("Pragma: no-cache"); '
|
||||
O="$O"' ?> '
|
||||
O="$O"' [ '
|
||||
O="$O"$(arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print "\""$2"\", " }' | grep :.*: | sort | uniq)
|
||||
O="$O"' ] '
|
||||
echo "$O"
|
||||
echo "$O" > "$OUT"
|
||||
NETMASK="$(ip -4 addr show "$IF" | egrep -o "brd [0-9\.]*" | egrep -o "[0-9\.]*")"
|
||||
MACS=""
|
||||
for M in $(sudo arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print $2 }' | grep :.*: | sort | uniq)
|
||||
do
|
||||
[ -n "$MACS" ] && MACS="$MACS,$M" || MACS="$M";
|
||||
done
|
||||
POST="sn=$NETMASK&macs=$MACS"
|
||||
RESULT=$(wget "$OUT" -O - --quiet --post-data "$POST" || echo "wget error: $?")
|
||||
if [ -n "$RESULT" ]
|
||||
then
|
||||
echo Error uploading results:
|
||||
echo "$RESULT"
|
||||
fi
|
||||
echo $(date)" sleeping..."
|
||||
sleep "$SLEEP"
|
||||
done
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
*/
|
||||
|
||||
header("Content-type: text/plain");
|
||||
require_once("../config.php");
|
||||
require_once("util.php");
|
||||
require_once("config.php");
|
||||
require_once("lib/util.php");
|
||||
|
||||
function echoln($str) {
|
||||
echo("$str\n");
|
Loading…
Reference in New Issue
Block a user