From b77e986a168f63e0e79957f1620d540599358570 Mon Sep 17 00:00:00 2001 From: sandb Date: Tue, 29 Dec 2009 22:53:31 +0100 Subject: [PATCH] downloading of script, script updated, support for distrib upload finalized (i think) --- img/ccc.png | Bin 90353 -> 90353 bytes img/dl-col.png | Bin 0 -> 1978 bytes img/dl.png | Bin 0 -> 1290 bytes js/pamela-buttons.js | 49 +++++++++++++++++++++++++-- js/pamela-nodes.js | 2 +- js/pamela.js | 17 +++------- macs.php | 9 +++-- pamela-scanner.sh | 63 +++++++++++++++++++++++++---------- lib/upload.php => upload.php | 4 +-- 9 files changed, 107 insertions(+), 37 deletions(-) create mode 100644 img/dl-col.png create mode 100644 img/dl.png rename lib/upload.php => upload.php (97%) diff --git a/img/ccc.png b/img/ccc.png index 542ac8c7d9710e1136e08c1f4f43a40fab6178c8..90b164ec26012901b6c26f2289b576a4405d918d 100644 GIT binary patch delta 37 scmex(koDt1)(PgE{~3UA!QSPQCpsu_$cpHTB{wopY0TJ~!PuDq07-cdtpET3 delta 37 qcmex(koDt1)(PgE3?T5+d3XIp2L%opCKDxZkrtW8jI9}roe2Q+lnfC7 diff --git a/img/dl-col.png b/img/dl-col.png new file mode 100644 index 0000000000000000000000000000000000000000..b19487477cfbf12f03618edc0eceeed5be8bfceb GIT binary patch literal 1978 zcmV;r2SxaaP)x1`y+ zkWNaYvZ?EqRsFC|nyM|CCauf5t=-h5>!fw6s!MAOqCzyaSwm7vl8y|O z5)y7EHW*`W!8QgHzx&|h<70emut7~8=}3p?JeS}3zqf-7a0Cbd;tst+z!6ElSFaout8HIHFD)qkfy>{g@8Wmx^ggedH#2gQ>mN1K+x8#^DXbY2yFxRU=smxe zo^!hqVUOaMRFbMdwcm8^W)}d93sZ!H{fgf|c^LrzWQS&6aHbQ0@ccLn!M?O=y05;# ztwleP#Q>4;cwAAHqy|)`%ux|x+CZ3**eAvA`o=lA58t0=KI zBk7D$1=LOSsptQcw~g7!j{(Td+e|^>wnW0EpfN=Od?WACbMdL9V2|^iBwu*m$Bk>R z0uZ@1i@om2WKdna_EH=jz z04|G>XO_nDa_8=au4hw<+&0Y)B|(G@2;8>wzQ)HK<-==zX3Kne=uFc!o<37w52RrWn z17?dO3aX1wQiEQXps07WopDb)0A`DW>bgg?7W(oV{+RoH+|Dxu{4N&50VQ}YI7Yzl zBH(u^zDOiY!0%#gy!=Ww*Bwx5RMj+5bg+Y*+#>Y) z_^^(RcHkMg06?CllG-iJsKifHG}X|@=8@4<$o}Sk0nm2#=k$DX9Dx1Jr?3_^0`SHw zr2rIK>uG-My`&~y&wn{{`f;p9jXd=53B}*_@yp8ny*m!G-e^q9RWl`nO4^&U$yB7I znax%uCMVa%T+oNfT%wsb>ORNZoDbLV2ZR?U$jPw+;2ZxR02Yg#`i5_(R5Qku1Pa=# z_nv#6AmDdVT)d5q`Q?iL>)&{ZtDm0azAqfs%-g>Gdjw{0U@LCKVvZlXU%LMYeb-L& zm0i!KRWk`1`3t|OxPix?IJ@G+&%%zs^#J4EZXnHue6Hd0%= z7o#yJZJZFd=RF{`yTQFPg%zY`RN&*q@e1eGKy zA2<%|TCPB*ib|3+ohI}O&?JNitq2tOGO&L+NPyf8=4BPlGZm=+%uf@#3)lm^yYxXS z&Tw3udL1kDw@E@QG zptPux7oTaN$Xc-~$ngmmPaoZfXWSWc4FbD`5W}f*(t^scl`^aYpsd)zAAi$=t#DIT zkiJPbKl|N2M!iEZ*N_b9OqsM2P#M-C!&U;6msIicbFJ74%hP0OL5^_fxh6)&24gO# z3^|lKD+5p&wn~Pz15}jN@XBvnu@#oB5OS0sKih8rG_QR;xahNs`nEyiW8}?lB?6Cu>#v|4FE1Vm5n$$^ZZW M07*qoM6N<$g1}O`hX4Qo literal 0 HcmV?d00001 diff --git a/img/dl.png b/img/dl.png new file mode 100644 index 0000000000000000000000000000000000000000..875e4def07768b023caefabe8da58040a912aefd GIT binary patch literal 1290 zcmV+l1@-!gP)`&E)imkG>ZZ&3 zD{-SXLU%4*y7VvbN8-Yj4$+lyVX8(G6O-yfjg7HtqQshLx&SK-lmbeN9vAlv^L)HJ zb017XN&If!opaB<@56cL{zSk@;31%cn^SAR`Q5;?+`NzgyMUnzP;tW=FuQ#`h3Y5p zbyPCOSu=Zmn}7->={evw2w~k3N&=NMB57aFwnx&aq-YVMHYfxR;Q~gPE!ml9qGsJ(5lVHQ=I|{oMj8|E@cM zA^-UYFr5qv+yy*YV86e>whwsF%bma%>6idKoGE{1W>(}B`}B)IVS^UhkXy|pX^ch+ z%>qBfd&7-7_BC+ue=zNGE+{9CZr9f`buQLN`ZYT(r%2f7>wmMH1#EU z9=MnS2??7L;A@~4n9gk$&H?uUpGVq#L&)73Gs`Z!p91#)pQJ`J3DnG%fcFaQQ@~V< zcIOK07k~??fOYMdjdM1l-I9(+J&W}hFlA;pnmPIA`fftbmeKkgo&`MsoG#fBz*oRW zEqorKc;}U@UBGW!>43(1-AuP{@g36@;2pwBlrjTkwVCJxd{EN=2JmCWr;cySzReec z((+MXT03Uc{}0-3?HJJ5#<>f4g0!iplq9{-qQ*26~xrL^zmx*=o*jnXnsbrSrhv0?1Cc*Ht5I*f&VA6RM;Gz**oHH!T2F zGh0XiYbi;6zyytB%{=gC(Y+Hi8BE@wO5+^g2aHSVZ3AR4FrI^~#vq%5I_yAS^(KY_}ujY zdX*5#q?}Kl@Xc(V5ZQVj-AagTOIY`r@HTiKRqr!NrBkix*WA=ki0lSfw@uKvalS_Q+_k)K+d&<6ju6=_?0EM4?&a|uWOWl)lcB#RSCXw8 zOZ|k1)uVZZ5N#ZCz{^Vxx#@qnZ3z^ju+T_0-pDe_6Q8macs = 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 '"]'; diff --git a/pamela-scanner.sh b/pamela-scanner.sh index d419bf8..4aedeee 100755 --- a/pamela-scanner.sh +++ b/pamela-scanner.sh @@ -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"' ' - 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 diff --git a/lib/upload.php b/upload.php similarity index 97% rename from lib/upload.php rename to upload.php index bcd7b25..2502a0e 100644 --- a/lib/upload.php +++ b/upload.php @@ -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");