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
|
//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
|
// Class IFace buttons
|
||||||
function IFaceButtons() {
|
function IFaceButtons() {
|
||||||
this.buttons = [];
|
this.buttons = [];
|
||||||
|
@ -91,11 +122,11 @@ IFaceButtons.prototype.add = function(button) {
|
||||||
};
|
};
|
||||||
|
|
||||||
IFaceButtons.prototype.reposition = function() {
|
IFaceButtons.prototype.reposition = function() {
|
||||||
var x = width - 64;
|
var x = 20;
|
||||||
var y = height - 64;
|
var y = height - 64;
|
||||||
for (var i = 0; i < this.buttons.length; i++) {
|
for (var i = 0; i < this.buttons.length; i++) {
|
||||||
this.buttons[i].moveTo(x, y);
|
this.buttons[i].moveTo(x, y);
|
||||||
x -= 64;
|
x += 64;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,3 +135,17 @@ IFaceButtons.prototype.draw = function() {
|
||||||
this.buttons[i].draw();
|
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;
|
s *= 2;
|
||||||
//var x = Math.floor(this.projection.x - (186 / s));
|
//var x = Math.floor(this.projection.x - (186 / s));
|
||||||
//var y = Math.floor(this.projection.y - (50 / 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));
|
var y = Math.floor(this.projection.y - (180 / s));
|
||||||
context.drawImage(this.norbert, x, y);
|
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.buttons = new IFaceButtons();
|
||||||
this.fullScreenButton = new FullScreenButton();
|
this.downloadScriptButton = new DownloadScriptButton();
|
||||||
this.buttons.add(this.fullScreenButton);
|
this.buttons.add(this.downloadScriptButton);
|
||||||
this.resize();
|
this.resize();
|
||||||
|
|
||||||
this.m = new Matrix();
|
this.m = new Matrix();
|
||||||
|
@ -114,20 +114,13 @@ Pamela.prototype.start = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Pamela.prototype.mousemove = function(event) {
|
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.x = event.offsetX;
|
||||||
this.mouse.y = event.offsetY;
|
this.mouse.y = event.offsetY;
|
||||||
};
|
};
|
||||||
|
|
||||||
Pamela.prototype.mouseclick = function(event) {
|
Pamela.prototype.mouseclick = function(event) {
|
||||||
if (this.fullScreenButton.isHovered(event.offsetX, event.offsetY))
|
this.buttons.mouseclick(event);
|
||||||
this.fullScreenButton.execute();
|
|
||||||
};
|
|
||||||
|
|
||||||
Pamela.prototype.mousein = function(event) {
|
|
||||||
};
|
|
||||||
|
|
||||||
Pamela.prototype.mouseout = function(event) {
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pamela.prototype.fire = function() {
|
Pamela.prototype.fire = function() {
|
||||||
|
@ -199,7 +192,7 @@ Pamela.prototype.resize = function() {
|
||||||
|
|
||||||
Pamela.prototype.updateEntries = function() {
|
Pamela.prototype.updateEntries = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
$.getJSON("js/input.php", function(data) {
|
$.getJSON("macs.php", function(data) {
|
||||||
self.updateNodes(data);
|
self.updateNodes(data);
|
||||||
});
|
});
|
||||||
self.entriesTimer = setTimeout(function() { self.updateEntries(); }, 60000);
|
self.entriesTimer = setTimeout(function() { self.updateEntries(); }, 60000);
|
||||||
|
|
9
macs.php
9
macs.php
|
@ -38,13 +38,13 @@ class Macs {
|
||||||
|
|
||||||
private function readFile($filename) {
|
private function readFile($filename) {
|
||||||
$mcs = file_get_contents($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) {
|
private function readFiles($directory) {
|
||||||
$macFiles = scandir($directory);
|
$macFiles = scandir($directory);
|
||||||
foreach ($macFiles as $macFile) {
|
foreach ($macFiles as $macFile) {
|
||||||
if (preg_match("/\.macs$/", $macFile) != 1)
|
if (preg_match("/.+\.macs$/", $macFile) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$filename = "$directory/$macFile";
|
$filename = "$directory/$macFile";
|
||||||
|
@ -64,6 +64,11 @@ class Macs {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createJson() {
|
private function createJson() {
|
||||||
|
if (count($this->macs) < 1) {
|
||||||
|
echo '[]';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
echo '["';
|
echo '["';
|
||||||
echo implode('", "', $this->macs);
|
echo implode('", "', $this->macs);
|
||||||
echo '"]';
|
echo '"]';
|
||||||
|
|
|
@ -21,39 +21,66 @@
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
IF='eth0'
|
function usage {
|
||||||
OUT='js/input.php'
|
|
||||||
|
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'
|
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
|
if [ $? != 0 ] ; then echo "Could not parse parameters..." >&2 ; exit 1 ; fi
|
||||||
eval set "$TEMP" --
|
eval set "$TEMP"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
shift;
|
||||||
|
[ -z "$1" ] && break;
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-i) IF="$2"; shift;;
|
-i) IF="$2"; shift;;
|
||||||
-o) OUT="$2"; shift;;
|
-o) OUT="$2"; shift;;
|
||||||
-s) SLEEP="$2"; shift;;
|
-s) SLEEP="$2"; shift;;
|
||||||
--) break;;
|
-h|'-?') usage; break;;
|
||||||
|
*) echo "Unknown param: [$1]"; usage; exit 1;
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
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
|
while true
|
||||||
do
|
do
|
||||||
echo $(date)" scanning..."
|
echo $(date)" scanning..."
|
||||||
O="";
|
NETMASK="$(ip -4 addr show "$IF" | egrep -o "brd [0-9\.]*" | egrep -o "[0-9\.]*")"
|
||||||
O="$O"'<?php '
|
MACS=""
|
||||||
O="$O"' header("Content-type: application/pdf"); '
|
for M in $(sudo arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print $2 }' | grep :.*: | sort | uniq)
|
||||||
O="$O"' header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); '
|
do
|
||||||
O="$O"' header("Cache-Control: no-cache"); '
|
[ -n "$MACS" ] && MACS="$MACS,$M" || MACS="$M";
|
||||||
O="$O"' header("Pragma: no-cache"); '
|
done
|
||||||
O="$O"' ?> '
|
POST="sn=$NETMASK&macs=$MACS"
|
||||||
O="$O"' [ '
|
RESULT=$(wget "$OUT" -O - --quiet --post-data "$POST" || echo "wget error: $?")
|
||||||
O="$O"$(arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print "\""$2"\", " }' | grep :.*: | sort | uniq)
|
if [ -n "$RESULT" ]
|
||||||
O="$O"' ] '
|
then
|
||||||
echo "$O"
|
echo Error uploading results:
|
||||||
echo "$O" > "$OUT"
|
echo "$RESULT"
|
||||||
|
fi
|
||||||
echo $(date)" sleeping..."
|
echo $(date)" sleeping..."
|
||||||
sleep "$SLEEP"
|
sleep "$SLEEP"
|
||||||
done
|
done
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
header("Content-type: text/plain");
|
header("Content-type: text/plain");
|
||||||
require_once("../config.php");
|
require_once("config.php");
|
||||||
require_once("util.php");
|
require_once("lib/util.php");
|
||||||
|
|
||||||
function echoln($str) {
|
function echoln($str) {
|
||||||
echo("$str\n");
|
echo("$str\n");
|
Loading…
Reference in New Issue
Block a user