-
Notifications
You must be signed in to change notification settings - Fork 1
/
scan
172 lines (149 loc) · 3.84 KB
/
scan
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
nocolors=false
rate="1000"
unset OPTIND
unset OPTARG
OPTARG=""
function print_banner {
echo -e "${GREEN}
_____ ___ ___ __ _ _ ____ ___ __ __ _ _ __ _____
|_____/ __|/ __/ _\` | '_ \ \ /\ / / '__/ _\` | '_ \|_____|
|_____\__ \ (_| (_| | | | \ V V /| | | (_| | |_) |_____|
|___/\___\__,_|_| |_|\_/\_/ |_| \__,_| .__/
|_| ${NC}"
echo -e "${GREEN}
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█ █
█ █
█ ▄▄ █
█ ██ █
█ ▀▀ █
█ ▀▀▀▀▀ █
█ █
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
${WHITE}wrapped with love by unkn0wnsyst3m
${TEAL}https://mfnttps.github.io/
${TEAL}https://github.com/unkn0wnsyst3m/${NC}"
}
function help_menu {
echo -e "usage:
$0 -t <target> [-r] <rate> [-n]
${RED}Mandatory: -t <target>${NC}"
print_banner
exit 1
}
if [ $# -eq 0 ]; then
help_menu
fi
while getopts ":r:t:nh" flag
do
case $flag in
t) ip=$OPTARG
;;
r) rate=$OPTARG
;;
n) nocolors=true
;;
h) help_menu
;;
?) help_menu
;;
esac
done
if [[ $nocolors = true ]]
then
RED='\033[0m'
GREEN='\033[0m'
NC='\033[0m'
BLUE='\033[0m'
TEAL='\033[0m'
WHITE='\033[0m'
else
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
BLUE='\033[0;34m'
TEAL='\033[0;36m'
WHITE='\033[0;0m'
fi
if [[ $ip = "" ]]; then
help_menu
fi
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
savefile="$ip.nmapsave"
print_banner
echo -e "${RED}
===================================
| Target Information |
===================================
Target ......... $ip
Rate ........... $rate
Savefile ....... $ip.nmapsave
${NC}" | tee -a $savefile
sleep 2
function scan() {
ip="$1"
echo -e "${BLUE}"
echo "**************************************"
echo " TCP Port Scanning: $1"
echo "**************************************"
echo -e "${GREEN}"
echo "[*] Running a TCP scan against all ports"
echo -e "${NC}"
output=$(sudo nmap -p- --min-rate=$rate -T5 $ip -Pn)
echo "$output"
tcpports=$(echo "$output" | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
echo -e "${BLUE}"
echo "***************************************************"
echo "* UDP Port Scanning Top 1000: $1"
echo "***************************************************"
echo -e "${GREEN}"
echo "[*] Running a UDP scan against top 1000 ports"
echo -e "${NC}"
output=$(sudo nmap -sU --top-ports=1000 --min-rate=$rate -T5 $ip -Pn)
echo "$output"
udpports=$(echo "$output" | grep open | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//)
echo -e "${BLUE}"
echo "**************************************"
echo " Service Scanning $1"
echo "**************************************"
echo -e "${NC}"
if [[ ! -z "tcpports" ]]
then
echo -e "${GREEN}"
echo "[*] Running TCP Service Scan: $tcpports"
echo -e "${NC}"
output=$(sudo nmap -O -sC -sV --min-rate=$rate -p $tcpports $ip -Pn)
echo "$output"
echo ""
fi
if [[ ! -z "$udpports" ]]
then
echo -e "${GREEN}"
echo "[*] Running UDP Service Scan: $udpports"
echo -e "${NC}"
output=$(sudo nmap -O -sC -sV --min-rate=$rate -p $udpports $ip -Pn)
echo "$output"
echo ""
fi
}
if [[ "$ip" == *"-"* ]]
then
echo -e "${BLUE}[*] Scanning an IP Range${NC}"
var1=$(echo "$ip" | cut -f1 -d-)
#echo $var1
var2=$(echo "$ip" | cut -f2 -d-)
#echo $var2
ip_list=$(prips $var1 $var2)
echo -e "${BLUE}[+] Range: $ip_list${NC}"
for ip in $ip_list
do
echo -e "${BLUE}[*] Save Location: $ip.nmapsave${NC}"
scan $ip | tee $ip.nmapsave
done
else
scan $ip | tee $ip.nmapsave
fi