-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommon
More file actions
executable file
·306 lines (266 loc) · 9.5 KB
/
Copy pathcommon
File metadata and controls
executable file
·306 lines (266 loc) · 9.5 KB
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# ==
# == DEFINIZIONE DELLE FUNZIONI
# ==
# Funzione per gestire la logica di creazione del folder di appoggio dati
manageFolder() {
# Parametro passato alla funzione (nomeCartella)
local nomeCartella="$1"
# Ottieni il percorso del desktop dell'utente corrente
local desktopPath="$HOME/Desktop"
# Percorso completo della cartella specificata sul desktop
local cartellaCompleta="$desktopPath/$nomeCartella"
# Verifica se la cartella esiste sul desktop
if [ ! -d "$cartellaCompleta" ]; then
mkdir "$cartellaCompleta"
fi
# Entra nella cartella
cd "$cartellaCompleta" || exit
# Verifica se esiste il file readme.txt
if [ -f "readme.txt" ]; then
# Il file readme esiste quindi lo apro
xdg-open "readme.txt"
else
# se non esiste lo creo e lo apro
touch "readme.txt"
echo "$ip" > readme.txt
echo "$domain" >> readme.txt
# Apri il file readme.txt
xdg-open "readme.txt"
fi
# Apri la cartella
xdg-open "$cartellaCompleta" >/dev/null 2>&1
# Restituisci il percorso completo della cartella
echo "$cartellaCompleta"
}
# Genero il file con gli users
generate_users() {
local file_path=$1
# Verifica se il file esiste, altrimenti lo crea
if [ ! -e "$file_path" ]; then
touch "$file_path"
names=("admin" "" "administrator" "user" "guest" "root" "(name of box)" "wampp" "public" "private" "manager" "support" "backup" "tomcat")
for name in "${names[@]}"; do
echo "$name" >> "$file_path"
done
fi
# Se il file esiste già non lo tocca
}
# Genero il file con le password
generate_passwords() {
local file_path=$1
# Verifica se il file esiste, altrimenti lo crea
if [ ! -e "$file_path" ]; then
touch "$file_path"
names=("admin" "" "password" "administrator" "(name of box)" "user" "12345" "guest" "root" "xampp" "public" "private" "manager" "tomcat" "secret" "s3cret")
for name in "${names[@]}"; do
echo "$name" >> "$file_path"
done
fi
# Se il file esiste già non lo tocca
}
#!/bin/bash
# Funzione per estrarre l'IP dall'URL
get_ip() {
url=$1
ip=$(dig +short "$(echo "$url" | grep -oP '(?<=://)[^/]+')" | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}')
echo "$ip"
}
# Funzione per estrarre il dominio dall'URL
get_domain() {
url=$1
domain=$(echo "$url" | awk -F[/:] '{print $4}' | awk -F. '{
if (NF == 2 || (NF == 3 && length($(NF-1)) > 3)) {
print $(NF-1)"."$NF
} else {
print $(NF-2)"."$(NF-1)"."$NF
}
}')
echo "$domain"
}
# Funzione per estrarre il sito web dall'URL
get_website() {
url=$1
website=$(echo "$url" | grep -oP '://\K[^/]+')
echo "$website"
}
# Program version
show_version() {
echo ""
echo ""
echo ' /$$ /$$ /$$$$$$ /$$ '
echo ' |__/ | $$ /$$__ $$ |__/ '
echo ' /$$$$$$$ /$$ /$$$$$$ /$$$$$$ | $$ \__/ /$$$$$$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$ '
echo ' /$$_____/| $$|_ $$_/ /$$__ $$| $$$$$$ | $$__ $$| $$ /$$__ $$ /$$__ $$ /$$__ $$'
echo ' | $$$$$$ | $$ | $$ | $$$$$$$$ \____ $$| $$ \ $$| $$| $$ \ $$| $$$$$$$$| $$ \__/'
echo ' \____ $$| $$ | $$ /$$| $$_____/ /$$ \ $$| $$ | $$| $$| $$ | $$| $$_____/| $$ '
echo ' /$$$$$$$/| $$ | $$$$/| $$$$$$$| $$$$$$/| $$ | $$| $$| $$$$$$$/| $$$$$$$| $$ '
echo ' |_______/ |__/ \___/ \_______/ \______/ |__/ |__/|__/| $$____/ \_______/|__/ '
echo ' | $$ '
echo ' | $$ '
echo ' |__/ '
echo ""
echo "version 2.5.5"
echo ""
echo ""
}
# Funzione per mostrare i valori e chiedere conferma/modifica
confirm_values() {
value_type=$1
value=$2
read -e -p "Confirm or modify the $value_type [$value]: " new_value
new_value=${new_value:-$value} # Usa il valore precedente se non viene inserito uno nuovo
echo "$new_value"
}
# Funzione per mostrare i valori
show_values() {
echo "Target IP: $1"
echo "Target Web Site: $2"
echo "Target Domain: $3"
echo "Project Folder /$4/"
echo "Attacker IP: $5"
}
# Funzione per chiedere all'utente l'URL
ask_for_url() {
read -p "Inserisci l'URL: " url
}
get_publicIP() {
local interface=$1
local public_ip
local private_ip
# Se l'interfaccia è tun0 o simili (VPN), non forzare l'interfaccia in curl
if [[ "$interface" =~ ^tun ]]; then
# Ottieni l'IP pubblico reale senza specificare interfaccia (esce tramite la VPN)
public_ip=$(curl -s https://api.ipify.org)
else
# Per interfacce normali, usa curl con --interface
public_ip=$(curl -s --interface "$interface" https://api.ipify.org)
fi
# Verifica se l'IP pubblico è valido
if [[ -n "$public_ip" && "$public_ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$public_ip"
else
# Se non esiste un IP pubblico valido, ottieni l'IP privato dell'interfaccia
private_ip=$(ip addr show "$interface" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
echo "$private_ip"
fi
}
# ==
# == MY MAIN
# ==
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <Interface> <Target site>"
echo " - Interface: Interface from which attacker exexutes action"
echo " - Target site: if target is a web site, this is site root with protocol definition. If target has no web site fill this field as you want"
echo ""
echo "Example:"
echo "$0 tun0 http://www.hackedbox.htb"
exit 1
fi
iface=$1
url=$2
# Estrai valori
ip=$(get_ip "$url")
website=$(get_website "$url")
domain=$(get_domain "$url")
fold=$domain
# Mostra i valori e chiedi conferma/modifica
show_version
ip=$(confirm_values "Target IP" "$ip")
website=$(confirm_values "web site" "$website")
domain=$(confirm_values "domain" "$domain")
fold=$(confirm_values "project folder" "$fold")
# Attacker interface
attackerInt=$1
# Attacker IP
#attackerIP=$(ip addr show $attackerInt | grep 'inet ' | awk -F' ' '{print $2}'| awk -F'/' '{print $1}')
attackerIP=$(get_publicIP "$attackerInt")
attackerIP=$(confirm_values "attacker IP" "$attackerIP")
# Mostra i valori trovati o inseriti
show_values "$ip" "$website" "$domain" "$fold" "$attackerIP"
#=============== Variabili per moduli applicativi =================
# target url
url=$url
# target IP
ip=$ip
# target DOMAIN
domain=$domain
# target site
site=$website
folderAppo=$fold
# wp-press test token per analizzare il sito target
wptoken="20En7agrVr8NXWYdZ8CczavcXaJaFYdRm6sWyhPEJu8"
# cartella principale del progetto /target/
folderProject=$(manageFolder "$folderAppo")
echo "Result Bucket Folder: $folderProject"
# PathFile con Users e Password
pathFile_users="$folderProject/users.txt"
pathFile_passwords="$folderProject/passwords.txt"
folderProjectInfoGathering="$folderProject/InfoGathering"
folderProjectWebInfo="$folderProject/WebInfoGathering"
folderProjectQucikWin="$folderProject/QuickWin"
folderProjectAuthN="$folderProject/AuthNbypass"
folderProjectWebAuthN="$folderProject/WebAuthNbypass"
folderProjectServiceInfoGathering="$folderProject/ServiceInfoGathering"
folderProjectWebFingerprint="$folderProject/WebFingerprint"
folderProjectEngine="$folderProjectWebAuthN/engine"
folderProjectWebStuff="$folderProject/WebAuthNStuff"
folderProjectToTarget="$folderProject/toTarget"
folderProjectFromTarget="$folderProject/fromTarget"
folderProjectCrack="$folderProject/crack"
#echo "$folderProjectCrack - $folderProjectFromTarget - $folderProjectToTarget"
#===================================================================
# Creo il file con users e passwords
generate_users "$pathFile_users"
generate_passwords "$pathFile_passwords"
# Preparo il il filesystem che conterrà i risultati delle analisi
if [ ! -d "$folderProjectInfoGathering" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectInfoGathering"
fi
if [ ! -d "$folderProjectServiceInfoGathering" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectServiceInfoGathering"
fi
if [ ! -d "$folderProjectQucikWin" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectQucikWin"
fi
if [ ! -d "$folderProjectWebFingerprint" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectWebFingerprint"
fi
if [ ! -d "$folderProjectWebInfo" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectWebInfo"
fi
if [ ! -d "$folderProjectWebAuthN" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectWebAuthN"
fi
if [ ! -d "$folderProjectWebStuff" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectWebStuff"
fi
if [ ! -d "$folderProjectToTarget" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectToTarget"
fi
if [ ! -d "$folderProjectFromTarget" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectFromTarget"
fi
if [ ! -d "$folderProjectCrack" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectCrack"
fi
if [ ! -d "$folderProjectAuthN" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectAuthN"
fi
#preparo il folder con i file di appoggio per command injection
if [ ! -d "$folderProjectEngine" ]; then
# Se non esiste, crea la cartella
mkdir -p "$folderProjectEngine"
fi
#copio i file dalla cartella di appoggio a quella di destinazione sul folder del progetto target sovrascrivendo nel caso siano già presenti
cp -f ./engine/* "$folderProjectEngine"