-
Notifications
You must be signed in to change notification settings - Fork 0
/
portscan-udp.sh
executable file
·48 lines (41 loc) · 1.3 KB
/
portscan-udp.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
#!/bin/sh
set -eu
usage() {
echo "Usage: ${0##*/} <target-hosts-list.txt> <exclude-hosts-list.txt>"
}
if [ "$#" -eq 0 ]; then
echo "Error: Target hosts must be specified"
usage
exit 1
fi
if [[ "$1" == "-h" ]]; then
usage
exit 0
fi
hosts=$(<$1)
echo "Target: ${hosts}"
today=`date +%Y%m%d`
if [ ! -d ./results/${today} ]; then
mkdir -p ./results/${today}
fi
if [ "$#" -eq 2 ]; then
exclude_hosts=`cat $2`
for h in ${hosts[@]}
do
host_name=`echo $h | tr "/" "_"`
now=`date +%Y%m%d_%H%M%S`
echo "Now Launching: nmap -v -sU -F --exclude ${exclude_hosts} -oX ./results/${today}/${host_name}_udp_${now}.xml -oN ./results/${today}/${host_name}_udp_${now}.txt ${h}"
# fastmode (top 100 ports)
sudo nmap -v -sU -F --exclude ${exclude_hosts} -oX ./results/${today}/${host_name}_udp_${now}.xml -oN ./results/${today}/${host_name}_udp_${now}.txt ${h}
done
fi
if [ "$#" -eq 1 ]; then
for h in ${hosts[@]}
do
host_name=`echo $h | tr "/" "_"`
now=`date +%Y%m%d_%H%M%S`
echo "Now Launching: nmap -v -sU -F -oX ./results/${today}/${host_name}_udp_${now}.xml -oN ./results/${today}/${host_name}_udp_${now}.txt ${h}"
# fastmode (top 100 ports)
sudo nmap -v -sU -F -oX ./results/${today}/${host_name}_udp_${now}.xml -oN ./results/${today}/${host_name}_udp_${now}.txt ${h}
done
fi