-
Notifications
You must be signed in to change notification settings - Fork 0
/
RPIdetect.sh
96 lines (86 loc) · 2.26 KB
/
RPIdetect.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /bin/bash
#################
### @name, RPIdetect
### @author, rizacantufan
### @version, v1.0
### @mail, [email protected]
#################
#nmap installed control
if ! dpkg -S `which nmap` > /dev/null; then
echo -e "Nmap not found! Install? (y/n) \c"
read
if "$REPLY" = "y"; then
sudo apt-get install nmap
fi
fi
case "$1" in
-h|--help)
echo "RPIdetect - attempt to capture frames"
echo " "
echo "RPIdetect [options] [ip address]"
echo " "
echo "options:"
echo "-h show brief help"
echo "-i specify an action to use. Not required!"
exit 0
;;
-i)
shift
if [ "$1" ]; then
export IP=$1
else
echo "IP address must be specified"
exit 1
fi
;;
*)
shift
#get Default gateway ip address on system.
export IP=$(/sbin/ip route | awk '/default/ { print $3 }')
echo "Default Gateway:$IP"
if [ -z "$IP" ] ; then
echo 'Local Network not connection!'
exit 1
fi
shift
;;
esac
if [[ ! "$IP" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
echo "IP Address format is incorrect!"
exit 1
fi
#Use The Constat Info.
mac_address=(
'98:4F:EE:' # Galileo Default MAC Prefix
'B8:27:EB:' # Raspberry PI Default MAC Prefix
'D4:94:A1:' # # Beagle Default MAC Prefix
)
system_info=(
'Raspberry'
'Pi'
'Galileo'
'Beagle'
'BeagleBoard'
'BeagleBone'
'Arduino'
'pcDuino'
'Kali'
'Linux'
'GNU'
'OpenBSD'
'FreeBSD'
'Centos'
'Redhat'
'NetBSD'
'Intel'
)
b=$(printf "\|%s" "${system_info[@]}\|${mac_address[@]}")
f=${b:2} # xxx\|xxx\| format
#Nmap scanned MAC addess and System info in Local Network
cikti=$(nmap -sP "$IP/24" | awk '/^Nmap/ { printf $5" " } /MAC/ { print }' - | grep -e "$f")
if [ -z "$cikti" ]; then
echo "The Embedded System could not be determined in Local network"
exit 1
fi
echo $cikti # Show the results