amoeba Posted August 22, 2012 Share Posted August 22, 2012 Is it possible on the status page to get like this: 44106 xx:xx:xx:xx:xx:xx 172.16.42.139 Android_356299040676213 xx:xx:xx:xx:xx:xx:xx - My HTC 44106 xx:xx:xx:xx:xx:xx 172.16.42.140 HP_laptop_john_doe xx:xx:xx:xx:xx:xx - New device 44106 xx:xx:xx:xx:xx:xx 172.16.42.141 sony_mobile_yadayada xx:xx:xx:xx:xx:xx - Known from DB What i mean is to add mac adresses in a textfile and the pineapple also adding mac's that connects in a "known from before" textfile Why? I have alot of devices and cant remember all mac's in my head, would be nice to see them lit up in green with custom name. Quote Link to comment Share on other sites More sharing options...
amoeba Posted August 25, 2012 Author Share Posted August 25, 2012 (edited) Work so far: Added file:/www/pineapple/includes/known.list #mac adresses of your devices /www/pineapple/includes/gen.sh #list creation script Changed begining of file: /www/pineapple/includes/logtail.php $cmd = "echo '<font color='red'>'; cat /www/pineapple/includes/unknown.out; echo '</font>'; echo '\n'; echo '<font color='lime'>'; cat /www/pineapple/includes/known.out; echo '</font>'; echo '\n'; cat /proc/net/arp; echo '\n'; grep KARMA: /tmp/karma.log |awk '!x[$0]++ || ($3 == \"Successful\") || ($3 == \"Checking\")'| sed -e 's/\(CTRL_IFACE \)\|\(IEEE802_11 \)//'"; Info: The file known.list should not contain empty lines chmod +x /www/pineapple/includes/known.list chmod +x /www/pineapple/includes/gen.sh Add a job to run gen.sh as often as you want your lists to refresh gen.sh #!/bin/bashrows=0;mac="xx:xx:xx:xx:xx"file="known.list"for f in known.list;dolet rows+=`wc $f | awk '{print $1}'`done# Use known.list to filter mac adresses from dhcp.leasesrm known.outsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do cat /tmp/dhcp.leases | grep $i >> known.out; done# Create unknown.outcat /tmp/dhcp.leases > connected.listcat connected.list > unknown.outsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"# echo ${array[0]} # outputs first linefor i in "${array[@]}"; do sed -i '/'$i'/d' unknown.out; done[/CODE] Edited August 27, 2012 by amoeba Quote Link to comment Share on other sites More sharing options...
WatskeBart Posted August 25, 2012 Share Posted August 25, 2012 Looks good so far and how about the known db devices? Quote Link to comment Share on other sites More sharing options...
amoeba Posted August 25, 2012 Author Share Posted August 25, 2012 Looks good so far and how about the known db devices? Known db is work in progress, soon there. Will post as soon as its done Quote Link to comment Share on other sites More sharing options...
amoeba Posted August 28, 2012 Author Share Posted August 28, 2012 (edited) Added some code for adding macadresses in a db and also color them orange if currently connected. The mac adresses will be updated in db everytime dh.sh is run, so recomended to add a job to run it every 24h Added files: /www/pineapple/includes/known.list #mac adresses of your devices /www/pineapple/includes/gen.sh #list creation script /www/pineapple/includes/db.sh #Create database file Changed begining of file: /www/pineapple/includes/logtail.php $cmd = "echo '<font color='red'>'; cat /www/pineapple/includes/unknown.out; echo '</font>'; echo '\n'; echo '<font color='orange'>'; cat /www/pineapple/includes/current_database.list; echo '</font>'; echo '\n'; echo '<font color='lime'>'; cat /www/pineapple/includes/known.out; echo '</font>'; echo '\n'; cat /proc/net/arp; echo '\n'; grep KARMA: /tmp/karma.log |awk '!x[$0]++ || ($3 == \"Successful\") || ($3 == \"Checking\")'| sed -e 's/\(CTRL_IFACE \)\|\(IEEE802_11 \)//'"; Info: The file known.list should not contain empty lines chmod +x /www/pineapple/includes/known.list chmod +x /www/pineapple/includes/gen.sh chmod +x /www/pineapple/includes/db.sh Add a job to run gen.sh as often as you want your lists to refresh Add a job to run db.sh as often as you want to refresh database file (recomended every 24h ) gen.sh #!/bin/bashrows=0;mac="xx:xx:xx:xx:xx"file="known.list"file2="connected.mac"for f in known.list; do let rows+=`wc $f | awk '{print $1}'` done#Create config filesif [ -e known.out ];thenrm known.outfiif [ ! -e database.out ];thentouch database.outfiiw dev wlan0 station dump > station.dumpcat station.dump | grep -e "Station" | cut -f 2 -d" " > connected.maccat /tmp/dhcp.leases > connected.allcat connected.list > unknown.outcat connected.list >> database.listsaveIFS="$IFS"IFS=$'\n'array=($(<$file2))IFS="$saveIFS"for i in "${array[@]}"; do cat connected.all | grep $i > connected.list; donemaccheck=$(cat connected.mac | wc -l)if [ "$maccheck" -eq "0" ];thencat connected.mac > connected.listfi#Use known.list to filter mac adresses from dhcp.leases and create known.outsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do cat /tmp/dhcp.leases | grep $i >> known.out; done#Edit unknown.outsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do sed -i '/'$i'/d' unknown.out; donesort current_database.list unknown.out | uniq -s 6 -u > temp_db2.outsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do sed -i '/'$i'/d' temp_db2.out; donecat temp_db2.out > unknown.outrm temp_db2.outsort unknown.out connected.list | uniq -s 6 -d > tmp.outcat tmp.out > unknown.outrm tmp.out#Edit current_database.listsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do sed -i '/'$i'/d' current_database.list; donesort current_database.list connected.list | uniq -s 6 -d > tmp.outcat tmp.out > current_database.listrm tmp.outsort current_database.list | uniq -s 6 > tmp.outcat tmp.out > current_database.listrm tmp.out[/CODE]db.sh[CODE]#!/bin/bashrows=0;mac="xx:xx:xx:xx:xx"file="known.list"file2="unknown.out"for f in known.list; do let rows+=`wc $f | awk '{print $1}'` done#Create database listcat database.list >> database.outsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do sed -i '/'$i'/d' database.out; doneawk -F, '!_[$1]++' database.out > temp_db.outcat temp_db.out > database.outsort connected.list database.out | uniq -s 6 > current_database.listsaveIFS="$IFS"IFS=$'\n'array=($(<$file))IFS="$saveIFS"for i in "${array[@]}"; do sed -i '/'$i'/d' current_database.list; donesort database.list unknown.out | uniq -s 6 -u > temp_db.outcat temp_db.out > unknown.outrm temp_db.outsort current_database.list | uniq -s 6 > tmp.outcat tmp.out > current_database.listrm tmp.out./gen.sh[/CODE] Edited August 29, 2012 by amoeba Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.