Jump to content

Status Page - Known Devices?


amoeba
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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/bash
rows=0;
mac="xx:xx:xx:xx:xx"
file="known.list"
for f in known.list;
do
let rows+=`wc $f | awk '{print $1}'`
done

# Use known.list to filter mac adresses from dhcp.leases
rm known.out
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do cat /tmp/dhcp.leases | grep $i >> known.out; done
# Create unknown.out
cat /tmp/dhcp.leases > connected.list
cat connected.list > unknown.out
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
# echo ${array[0]} # outputs first line
for i in "${array[@]}"; do sed -i '/'$i'/d' unknown.out; done
[/CODE]

screenbzg.jpg

Edited by amoeba
Link to comment
Share on other sites

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/bash
rows=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 files
if [ -e known.out ];
then
rm known.out
fi

if [ ! -e database.out ];
then
touch database.out
fi



iw dev wlan0 station dump > station.dump
cat station.dump | grep -e "Station" | cut -f 2 -d" " > connected.mac


cat /tmp/dhcp.leases > connected.all
cat connected.list > unknown.out
cat connected.list >> database.list

saveIFS="$IFS"
IFS=$'\n'
array=($(<$file2))
IFS="$saveIFS"
for i in "${array[@]}"; do cat connected.all | grep $i > connected.list; done
maccheck=$(cat connected.mac | wc -l)
if [ "$maccheck" -eq "0" ];
then
cat connected.mac > connected.list
fi


#Use known.list to filter mac adresses from dhcp.leases and create known.out
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do cat /tmp/dhcp.leases | grep $i >> known.out; done

#Edit unknown.out
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do sed -i '/'$i'/d' unknown.out; done
sort current_database.list unknown.out | uniq -s 6 -u > temp_db2.out
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do sed -i '/'$i'/d' temp_db2.out; done
cat temp_db2.out > unknown.out
rm temp_db2.out
sort unknown.out connected.list | uniq -s 6 -d > tmp.out
cat tmp.out > unknown.out
rm tmp.out

#Edit current_database.list
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do sed -i '/'$i'/d' current_database.list; done
sort current_database.list connected.list | uniq -s 6 -d > tmp.out
cat tmp.out > current_database.list
rm tmp.out
sort current_database.list | uniq -s 6 > tmp.out
cat tmp.out > current_database.list
rm tmp.out
[/CODE]

db.sh

[CODE]
#!/bin/bash

rows=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 list
cat database.list >> database.out
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do sed -i '/'$i'/d' database.out; done

awk -F, '!_[$1]++' database.out > temp_db.out
cat temp_db.out > database.out
sort connected.list database.out | uniq -s 6 > current_database.list
saveIFS="$IFS"
IFS=$'\n'
array=($(<$file))
IFS="$saveIFS"
for i in "${array[@]}"; do sed -i '/'$i'/d' current_database.list; done

sort database.list unknown.out | uniq -s 6 -u > temp_db.out
cat temp_db.out > unknown.out
rm temp_db.out
sort current_database.list | uniq -s 6 > tmp.out
cat tmp.out > current_database.list
rm tmp.out
./gen.sh
[/CODE]

Edited by amoeba
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...