-
Notifications
You must be signed in to change notification settings - Fork 0
/
portscan-tcp-rapid.sh
executable file
·61 lines (54 loc) · 2.72 KB
/
portscan-tcp-rapid.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
#!/bin/sh
set -eu
usage() {
echo "Usage: ${0##*/} -T<0-5> <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
today=`date +%Y%m%d`
if [ ! -d ./results/${today} ]; then
mkdir -p ./results/${today}
fi
timing_template=$1
hosts=`cat $2`
echo "Target: ${hosts}"
if [ "$#" -eq 3 ]; then
exclude_hosts=$(<$3)
for h in $hosts
do
host_name=`echo $h | tr "/" "_"`
# With the T4 option, all ports are often filtered...
# If SYN Scan(-sS) doesn't work, try TCP Connect Scan(-sT).
now=`date +%Y%m%d_%H%M%S`
# SYN Scan, Host discovery by TCP SYN Ping
echo "Now Launching: sudo nmap --exclude ${exclude_hosts} -v -n -PS22,80,443 -sS --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}"
sudo nmap ${timing_template} --exclude ${exclude_hosts} -v -n -PS22,80,443 -sS --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}
# ------------------------
# TCP Connect Scan, Host discovery by TCP SYN Ping
# echo "Now Launching: sudo nmap --exclude ${exclude_hosts} -v -n -sT --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}"
# sudo nmap --exclude ${exclude_hosts} -v -n -sT --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}
done
fi
if [ "$#" -eq 2 ]; then
for h in $hosts
do
host_name=`echo $h | tr "/" "_"`
# With the T4 option, all ports are often filtered...
# If SYN Scan(-sS) doesn't work, try TCP Connect Scan(-sT).
now=`date +%Y%m%d_%H%M%S`
# SYN Scan, Host discovery by TCP SYN Ping
echo "Now Launching: sudo nmap -v -n -PS22,80,443 -sS --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}"
sudo nmap ${timing_template} -v -n -PS22,80,443 -sS --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}
# ------------------------
# TCP Connect Scan, Host discovery by TCP SYN Ping
# echo "Now Launching: sudo nmap -v -n -PS22,80,443 -sT --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}"
# sudo nmap -v -n -PS22,80,443 -sT --host-timeout 30m -oX ./results/${today}/${host_name}_syn_ping_${now}.xml -oN ./results/${today}/${host_name}_syn_ping_${now}.txt ${h}
done
fi