-
Notifications
You must be signed in to change notification settings - Fork 0
/
1p.sh
247 lines (200 loc) · 8.99 KB
/
1p.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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
##ADD: (use nmap or masscan?)
##464/tcp open kpasswd5
#53/tcp open domain
if [ -z "$1" ]
then
echo -e "\nUsage: ./1p.sh <IP>"
exit 1
fi
printf "\n\n------ NMAP ------\n\n" > results
echo -e "\n\nRunning Nmap TCP...\n"
#nmap --top-ports 10000 --open -sS --min-rate 5000 $1 | tail -n +5 | head -n -1 >> results
#nmap -sS --top-ports 10000 --open -sV -n --min-rate 5000 $1 | tail -n +6 | head -n -1 >> results
#nmap -p- --open -sS --min-rate 5000 $1 -n -Pn | tail -n +6 | head -n -1 >> results
nmap -p- -sS --min-rate 5000 $1 -n -Pn | tail -n +6 | head -n -1 >> results
#nmap -p- -sS --min-rate 5000 $1 -n -Pn --max-rtt-timeout 10 --max-scan-delay 2 --min-hostgroup 10 | tail -n +6 | head -n -1 >> results
###ToOptimize
#ports=$(cat results | awk '{print $1}' | sed 's/\/tcp/,/g' | tr -d "\n" | sed '$ s/.$//' | sed 's/------PORT//g' | sed 's/,Nma//g' | sed 's/------Some//g' | sed 's/PORT//g' | sed 's/,Servic//g' | sed 's/------//g')
ports=$(cat results | awk '{print $1}' | sed 's/\/tcp/,/g' | tr -d "\n" | sed '$ s/.$//' | sed 's/,1SF.*")//g' | sed 's/------PORT//g' | sed 's/,Nma//g' | sed 's/------Some//g' | sed 's/PORT//g' | sed 's/,Servic//g' | sed 's/------//g' | sed 's/HostNot//g')
echo $ports
cat results
while read line
do
if [[ $line == *open* ]] && [[ $line == 445/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning SMB..."
smbclient -L //$1 -U "" -N >> tempsmb
#crackmapexec smb $1 >> tempsmb
elif [[ $line == *open* ]] && [[ $line == 161/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning SNMP..."
snmpwalk -c public -v2c $1 1.3.6.1.4.1.77.1.2.25 >> tempsnmp
elif [[ $line == *open* ]] && [[ $line == 25/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning SMTP..."
smtp-user-enum -U /usr/share/wordlists/dirbuster/apache-user-enum-2.0.txt -t $1 -m 150 >> tempsmtp
elif [[ $line == *open* ]] && [[ $line == 135/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning RPC..."
rpcdump.py -p 135 $1 >> rpcresult
elif [[ $line == *open* ]] && [[ $line == 2049/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning NFS..."
nmap --script=nfs-showmount $1 >> tempnfs
#/usr/sbin/showmount -e $1 >> tempnfs
elif [[ $line == *open* ]] && [[ $line == 137/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning NetBIOS..."
nmblookup -A $1 >> tempnb
nbtscan $1 > tempnb
elif [[ $line == *open* ]] && [[ $line == 138/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning NetBIOS..."
nmblookup -A $1 >> tempnb
nbtscan $1 >> tempnb
elif [[ $line == *open* ]] && [[ $line == 139/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning NetBIOS..."
nmblookup -A $1 >> tempnb
nbtscan $1 >> tempnb
elif [[ $line == *open* ]] && [[ $line == *ldap* ]] && [[ $line != *www.openssl.org* ]]
then
echo $line > ldaptmp
portsl=$(cat ldaptmp | awk '{print $1}' | sed 's/\/tcp/,/g' | sed '$ s/.$//')
echo -e "\nRunning LDAP port: $portsl ..."
printf "\n\n------ LDAP $portsl port ------\n\n" >> ldapresults
#nmap -p $portsl --script ldap\* --reason --min-rate 5000 $1 | tail -n +5 | head -n -1 >> ldapresults
nmap -p $portsl --script ldap-rootdse $1 | tail -n +5 | head -n -1 >> ldapresults
rm ldaptmp
#cat ldapresults
#if [ -e ldapresults ]
#then
# printf "\n\n------ LDAP $ports1 ------\n\n" >> results
# cat ldapresults >> results
# rm ldapresults
#fi
elif [[ $line == *open* ]] && [[ $line == 88/tcp* ]] && [[ $line != *www.openssl.org* ]]
then
echo -e "\nRunning Kerberos ..."
nmap -p 88 --script krb5-enum-users --script-args krb5-enum-users.realm='test' $1 | tail -n +5 | head -n -1 >> temp88
elif [[ $line == *open* ]] && [[ $line == *http* ]] && [[ $line != *www.openssl.org* ]]
then
echo $line > linetmp
portww=$(cat linetmp | awk '{print $1}' | sed 's/\/tcp/,/g' | sed '$ s/.$//')
#echo $portww
echo -e "\n\nRunning Gobuster port: $portww ..."
#echo $line
#gobuster dir -u http://$1:$portww/ -k -t 30 -b "404,400" -w /usr/share/wordlists/dirb/common.txt >> temp1
#gobuster dir -u $1 -t 100 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x txt,php,html,htm,aspx -qz > temp1
#gobuster dir -u http://$1:$portww/ -r -k -t 100 -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -x txt,php,html,aspx --wildcard >> temp1
#wfuzz -t 200 --hc 404 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt http://$1:$portww/FUZZ/ >> temp1
gobuster dir -u http://$1:$portww/ -r -k -t 70 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x txt,php,html,asp --wildcard --timeout 20s >> temp1
#gobuster dir -u http://$1:$portww/ -k -t 100 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x txt,php,html,asp --wildcard >> temp1
echo -e "\nRunning WhatWeb port: $portww ..."
#echo $line
#whatweb $1:$portww --open-timeout 3 --read-timeout 11 -v > temp2
whatweb $1:$portww -v > temp2
if [ -e temp1 ] && [[ $line != *Websit* ]] && [[ $line != *www.openssl.org* ]]
then
printf "\n\n------ DIRS $portww port------\n\n" >> results
cat temp1 >> results
rm temp1
fi
if [ -e temp2 ] && [[ $line != *Websit* ]] && [[ $line != *www.openssl.org* ]]
then
printf "\n\n------ WEB $portww port------\n\n" >> results
cat temp2 >> results
rm temp2
fi
fi
done < results
if [ -e temp88 ]
then
printf "\n\n------ Kerberos ------\n\n" >> results
cat temp88 >> results
rm temp88
fi
if [ -e tempsmb ]
then
printf "\n\n------ SMB ------\n\n" >> results
cat tempsmb >> results
rm tempsmb
fi
if [ -e tempsnmp ]
then
printf "\n\n------ SNMP ------\n\n" >> results
cat tempsnmp >> results
rm tempsnmp
fi
if [ -e rpcresult ]
then
printf "\n\n------ RPC ------\n\n" >> results
printf "SAVED IN FILE: rpcresult \n\n" >> results
fi
if [ -e tempsmtp ]
then
printf "\n\n------ SMTP ------\n\n" >> results
cat tempsmtp >> results
rm tempsmtp
fi
if [ -e tempnfs ]
then
printf "\n\n------ NFS ------\n\n" >> results
cat tempnfs >> results
rm tempnfs
fi
if [ -e tempnb ]
then
printf "\n\n------ NetBIOS ------\n\n" >> results
cat tempnb >> results
rm tempnb
fi
if [ -e ldapresults ]
then
#printf "\n\n------ LDAP ------\n\n" >> results
cat ldapresults >> results
rm ldapresults
fi
cat results
echo -e "\n\nRunning Nmap UDP...\n"
#nmap -n -p- -sU --open --reason --min-rate 4000 $1 | tail -n +6 | head -n -1 >> temp3
nmap -sU --top-ports 15000 --max-rtt-timeout 10 --max-scan-delay 2 --min-hostgroup 10 --reason --min-rate 2000 $1 -n >> temp3
#sudo nmap -sU -p- --open -sV --version-intensity 1 $1 -n -Pn | tail -n +6 | head -n -1 >> temp3
printf "\n\n------ UDP ------\n\n" >> results
cat temp3
cat temp3 >> results
while read line
do
if [[ $line == *open* ]] && [[ $line == 123/udp* ]]
then
#nmap -sU -sV --script "ntp* and (discovery or vuln) and not (dos or brute)" -p 123 $1 > tempntp
nmap -sU -sV --script "ntp* and (discovery or vuln) and not (dos or brute)" --reason --min-rate 5000 -p 123 $1 | tail -n +5 | head -n -1 > tempntp
#elif [[ $line == *open* ]] && [[ $line == 53/udp* ]]
#DNS tz > tempdns
fi
done < results
#if [ -e tempdns ]
#then
# printf "\n------ DNS ------\n\n" >> results
# cat tempdns >> results
# rm tempdns
#fi
if [ -e tempntp ]
then
printf "\n------ NTP ------\n\n" >> results
echo -e "\n\n------ NTP ------\n"
cat tempntp
cat tempntp >> results
rm tempntp
fi
rm temp3
#rm ldapresults
rm linetmp
#cat results
echo -e "\n\n\nRunning Detailed Nmap TCP...\n"
nmap -p$ports -sV -sC -n -Pn -reason --min-rate 5000 $1 | tail -n +5 | head -n -1 >> targeted
printf "\n\n------ Detailed NMAP ------\n\n" >> results
cat targeted
#cat temp4 >> results
#rm temp4