-
Notifications
You must be signed in to change notification settings - Fork 826
/
generateTargets.sh
executable file
·108 lines (89 loc) · 2.66 KB
/
generateTargets.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
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
# by Lee Baird (@discoverscripts)
# Check for root
if [ $EUID -ne 0 ]; then
echo
echo "[!] This script must be ran as root."
echo
exit 1
fi
f_targets(){
clear
f_banner
echo -e "${BLUE}SCANNING${NC}"
echo
echo "1. ARP scan"
echo "2. Ping sweep"
echo "3. Previous menu"
echo
echo -n "Choice: "
read -r CHOICE
case "$CHOICE" in
1) f_arpscan ;;
2) f_pingsweep ;;
3) f_main ;;
*) echo; echo -e "${RED}[!] Invalid choice or entry, try again.${NC}"; echo; sleep 2; "$DISCOVER"/generateTargets.sh ;;
esac
}
###############################################################################################################################
f_arpscan(){
echo
echo "[*] Scanning"
arp-scan --localnet | grep -Eiv '(interface|arp-scan|packets)' > tmp
sed '/^$/d' tmp | grep -v "$MYIP" | sort -t ' ' -k 1,1 -V > "$HOME"/data/arp-scan.txt
awk '{print $1}' tmp | grep -v "$MYIP" | $SIP | sed '/^$/d' > "$HOME"/data/arp-scan-targets.txt
rm tmp
echo
echo "$MEDIUM"
echo
echo "[*] Scan complete."
echo
echo -e "The new report is located at ${YELLOW}$HOME/data/arp-scan.txt${NC}"
echo
exit
}
###############################################################################################################################
f_pingsweep(){
echo
echo -e "${BLUE}Type of input:${NC}"
echo
echo "1. List containing IPs, ranges, and/or CIDRs."
echo "2. Manual"
echo
echo -n "Choice: "
read -r CHOICE
case "$CHOICE" in
1)
f_location
echo
echo "[*] Scanning"
nmap -sn -PS -PE --stats-every 10s -iL "$LOCATION" > tmp
;;
2)
echo
echo -n "Enter a CIDR or range: "
read -r MANUAL
# Check for no answer
if [ -z "$MANUAL" ]; then
f_error
fi
echo
echo "[*] Scanning"
nmap -sn -PS -PE --stats-every 10s "$MANUAL" > tmp
;;
*)
echo; echo -e "${RED}[!] Invalid choice or entry, try again.${NC}"; echo; sleep 2; "$DISCOVER"/generateTargets.sh ;;
esac
grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' tmp | grep -v "$MYIP" | $SIP > "$HOME"/data/pingsweep.txt
rm tmp
echo
echo "$MEDIUM"
echo
echo "[*] Scan complete."
echo
echo -e "The new report is located at ${YELLOW}$HOME/data/pingsweep.txt${NC}"
echo
exit
}
###############################################################################################################################
while true; do f_targets; done