forked from txthinking/google-hosts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find.sh
executable file
·62 lines (57 loc) · 1 KB
/
find.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
#!/usr/bin/env bash
#
# 这个是getssl.sh的一个wrapper
# EP:
# $ ./find 192.168.1.1/24
#
# Author: [email protected]
#
if [ $# -eq 0 ]
then
echo -e "Usage:\n";
echo -e " $ ./find.sh 192.168.1.1/24"
echo -e "\nView find.sh file to see more.\n"
exit 0;
fi
if [ ! -d output ]
then
mkdir output
fi
first=$(./iprange-$(uname)-$(uname -m) $1 | awk '{print $1}')
last=$(./iprange-$(uname)-$(uname -m) $1 | awk '{print $2}')
output=output/$first-$last
> $output
max_process=99
if [ $(uname) = "Darwin" ]
then
max_process=33
fi
fd=/tmp/google-hosts.fd
mkfifo $fd
exec 9<>$fd
rm $fd
for((i=0;i<$max_process;i++))
do
echo
done >&9
n=0
for((i=$first;i<$last;i++))
do
{
read -u9
{
ip=$(./d2ip-$(uname)-$(uname -m) $i)
out=$(./getssl.sh $ip)
echo -e "$out"
echo -e "$out" >> $output
echo >&9
}
}&
n=$(($n+1))
if [ $(($n%$(($max_process*2)))) -eq 0 ]
then
wait
fi
done
wait
exec 9>&-