Accelerate3g5 -- blobb » find_nano3G.sh
1 |
#!/bin/bash
|
---|---|
2 |
# Script finds nano3G femtocell on network according to its open ports.
|
3 |
|
4 |
if [ "$1" = "" ]; then |
5 |
echo "[ERROR] no interface (e.g. eth0) specified to search for nano3G" |
6 |
exit 1
|
7 |
fi
|
8 |
|
9 |
host_ip="$(ip address | grep $1 | grep inet \ |
10 |
| cut -d 't' -f2 | cut -d '/' -f1)" |
11 |
|
12 |
subnet="$(echo $host_ip | cut -d '.' -f1,2,3).1/24" |
13 |
|
14 |
echo "[INFO] seachring nano3G on $1..." |
15 |
|
16 |
|
17 |
hosts=$(nmap "${subnet}" | grep "scan report" | cut -d ' ' -f5) |
18 |
sleep 10 # documentum port (10002) closes for 10 s after port scan |
19 |
|
20 |
femtocell="" |
21 |
|
22 |
for host in $hosts; do |
23 |
if [ "$(nmap -Pn "$host" | grep tcp | tr '\n' ' ' \ |
24 |
| grep 22 | grep 8089 | grep 8090 | grep 10002)" != "" ]; then |
25 |
femtocell=$host |
26 |
echo "[INFO] Found nano3G on $femtocell" |
27 |
break
|
28 |
fi |
29 |
done
|
30 |
|
31 |
if [ "$femtocell" = "" ]; then |
32 |
echo "[ERROR] No femto cell found !!!" |
33 |
exit 1
|
34 |
fi
|