-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
1722 lines (1288 loc) · 87.2 KB
/
main.js
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
// To change the tabs for PreBuilt Queries, Custom Queries
function ChangeTab(evt, customTab) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(customTab).style.display = "block";
evt.currentTarget.className += " active";
}
// To set Nmap Command
function SetLDAP() {
// Variable Declaration
// IP address
var ip = document.getElementById("LDAP_IP").value;
var port = document.getElementById("LDAP_PORT").value;
var domain = document.getElementById("Domain").value; //use this for ADSearch
//Break Domain into parts for LDAPSearch.
var domain_array = domain.split(".")
//Find length of array if subdomain involved. Need 3 parts
if (domain_array.length===3){
var domain_part1 = domain_array[0];
var domain_part2 = domain_array[1];
var domain_part3 = domain_array[2];
}
else if (domain_array.length===2){
var domain_part1 = domain_array[0];
var domain_part2 = domain_array[1];
}
// PreBuilt-Query Mode
var PreBuiltMode = document.getElementById("PreBuilt-Mode");
//Set the ADSearch , LDAPSearch and Raw LDAP Query Value
// IF Statement if domain has 3 parts
if (domain_array.length===3){
//Find All Domain Users
if (PreBuiltMode.value === "Find all Domain Users") {
ldap_query = "(&(objectCategory=user)(objectClass=user))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find all Domain Admins") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(memberOf=CN=Domain Admins,CN=Users,DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find all Domain Groups") {
ldap_query = "(&(objectClass=group)(objectCategory=group))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Groups ending with 'admin' keyword") {
ldap_query_adsearch = "(&(objectClass=group)(objectCategory=group)(name=*admin))";
ldap_query_ldapsearch = "(&(objectClass=group)(cn=*admin))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query_adsearch+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query_ldapsearch+"\"";
var RAW_Command = ldap_query_adsearch;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Users with password never expires enabled") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=65536))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Controllers") {
ldap_query = "(&(objectClass=computer)(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Computers") {
ldap_query = "(&(objectClass=computer)(objectCategory=computer))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Decoy HoneyPot Accounts") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(logonCount=0)(badPwdCount=0))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Default User Accounts with password in Description") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(description=*password*))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Map Domain Trusts") {
ldap_query = "(&(objectClass=trustedDomain)(objectCategory=trustedDomain))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Principals with DCSync Rights") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(msDS-AllowedToActOnBehalfOfOtherIdentity=*))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "List all Kerberoastable Accounts") {
ldap_query = "(&(objectCategory=user)(servicePrincipalName=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find AS-REP Roastable Accounts (DontReqPreAuth)") {
ldap_query = "(&(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find UnConstrained Delegation Enabled Workstations") {
ldap_query = "(&(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304)(userAccountControl:1.2.840.113556.1.4.803:=524288))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Constrained Delegation Enabled Workstations") {
ldap_query = "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=524288)";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Interesting ACL") {
ldap_query_adsearch = "(&(|(ActiveDirectoryRights=GenericAll)(ActiveDirectoryRights=Write)(ActiveDirectoryRights=Create)(ActiveDirectoryRights=Delete)(ActiveDirectoryRights=ExtendedRight))(&(AceQualifier=Allow)(SecurityIdentifier=^S-1-5-.*-[1-9]\\d{3,}$)))";
ldap_query_ldapsearch = "(|(ActiveDirectoryRights=GenericAll)(ActiveDirectoryRights=Write)(ActiveDirectoryRights=Create)(ActiveDirectoryRights=Delete)(ActiveDirectoryRights=ExtendedRight))(&(AceQualifier=Allow)(SecurityIdentifier=^S-1-5-.*-[1-9]\\d{3,}$))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query_adsearch+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query_ldapsearch+"\"";
var RAW_Command = ldap_query_adsearch;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Workstations where Domain Users can RDP") {
ldap_query = "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=4096))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find LAPS Enabled Workstations") {
ldap_query = "(&(objectCategory=computer)(ms-Mcs-AdmPwdExpirationTime=*))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
}
// IF Statement if domain has 2 parts
else if (domain_array.length===2){
//Find All Domain Users
if (PreBuiltMode.value === "Find all Domain Users") {
ldap_query = "(&(objectCategory=user)(objectClass=user))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find all Domain Admins") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(memberOf=CN=Domain Admins,CN=Users,DC="+domain_part1+",DC="+domain_part2+"))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find all Domain Groups") {
ldap_query = "(&(objectClass=group)(objectCategory=group))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Groups ending with 'admin' keyword") {
ldap_query_adsearch = "(&(objectClass=group)(objectCategory=group)(name=*admin))";
ldap_query_ldapsearch = "(&(objectClass=group)(cn=*admin))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query_adsearch+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query_ldapsearch+"\"";
var RAW_Command = ldap_query_adsearch;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Users with password never expires enabled") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=65536))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Controllers") {
ldap_query = "(&(objectClass=computer)(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Domain Computers") {
ldap_query = "(&(objectClass=computer)(objectCategory=computer))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Decoy HoneyPot Accounts") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(logonCount=0)(badPwdCount=0))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Default User Accounts with password in Description") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(description=*password*))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Map Domain Trusts") {
ldap_query = "(&(objectClass=trustedDomain)(objectCategory=trustedDomain))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Principals with DCSync Rights") {
ldap_query = "(&(objectClass=user)(objectCategory=person)(msDS-AllowedToActOnBehalfOfOtherIdentity=*))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "List all Kerberoastable Accounts") {
ldap_query = "(&(objectCategory=user)(servicePrincipalName=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find AS-REP Roastable Accounts (DontReqPreAuth)") {
ldap_query = "(&(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find UnConstrained Delegation Enabled Workstations") {
ldap_query = "(&(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304)(userAccountControl:1.2.840.113556.1.4.803:=524288))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Constrained Delegation Enabled Workstations") {
ldap_query = "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=524288)";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Interesting ACL") {
ldap_query_adsearch = "(&(|(ActiveDirectoryRights=GenericAll)(ActiveDirectoryRights=Write)(ActiveDirectoryRights=Create)(ActiveDirectoryRights=Delete)(ActiveDirectoryRights=ExtendedRight))(&(AceQualifier=Allow)(SecurityIdentifier=^S-1-5-.*-[1-9]\\d{3,}$)))";
ldap_query_ldapsearch = "(|(ActiveDirectoryRights=GenericAll)(ActiveDirectoryRights=Write)(ActiveDirectoryRights=Create)(ActiveDirectoryRights=Delete)(ActiveDirectoryRights=ExtendedRight))(&(AceQualifier=Allow)(SecurityIdentifier=^S-1-5-.*-[1-9]\\d{3,}$))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query_adsearch+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query_ldapsearch+"\"";
var RAW_Command = ldap_query_adsearch;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find Workstations where Domain Users can RDP") {
ldap_query = "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=4096))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
else if (PreBuiltMode.value === "Find LAPS Enabled Workstations") {
ldap_query = "(&(objectCategory=computer)(ms-Mcs-AdmPwdExpirationTime=*))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command").value = LDAPSearch_Command;
document.getElementById("RAW_Command").value = RAW_Command;
}
}
}
// Copy button and the feedback
function CopyToClip(event) {
var buttonid = event.target.getAttribute("data-id");
var copyText = document.getElementById(buttonid);
navigator.clipboard.writeText(copyText.value);
var comment = event.target.querySelector(".commenttext");
comment.innerHTML = "Copied!";
}
// Copy button feedback reset
function ResetToClip(event) {
var comment = event.target.querySelector(".commenttext");
comment.innerHTML = "Copy to Clipboard";
}
// Set Built In Queries in dropdown
function BuiltInQueries() {
var domain = document.getElementById("Domain").value;
//Break Domain into parts
var domain_array = domain.split(".");
var domain_part1 = domain_array[0];
var domain_part2 = domain_array[1];
var domain_part3 = domain_array[2];
var options = [
{ value: "", text: "Please Select" },
{ value: "Find all Domain Users", text: "Find all Domain Users" },
{ value: "Find all Domain Admins", text: "Find all Domain Admins" },
{ value: "Find all Domain Groups", text: "Find all Domain Groups" },
{ value: "Find Domain Groups ending with 'admin' keyword", text: "Find Domain Groups ending with 'admin' keyword" },
{ value: "Find Domain Users with password never expires enabled", text: "Find Domain Users with password never expires enabled" },
{ value: "Find Domain Controllers", text: "Find Domain Controllers" },
{ value: "Find Domain Computers", text: "Find Domain Computers" },
{ value: "Find Decoy HoneyPot Accounts", text: "Find Decoy HoneyPot Accounts" },
{ value: "Find Default User Accounts with password in Description", text: "Find Default User Accounts with password in Description" },
{ value: "Map Domain Trusts", text: "Map Domain Trusts" },
{ value: "Find Principals with DCSync Rights", text: "Find Principals with DCSync Rights" },
{ value: "List all Kerberoastable Accounts", text: "List all Kerberoastable Accounts" },
{ value: "Find AS-REP Roastable Accounts (DontReqPreAuth)", text: "Find AS-REP Roastable Accounts (DontReqPreAuth)" },
{ value: "Find UnConstrained Delegation Enabled Workstations", text: "Find UnConstrained Delegation Enabled Workstations" },
{ value: "Find Constrained Delegation Enabled Workstations", text: "Find Constrained Delegation Enabled Workstations" },
{ value: "Find Interesting ACL", text: "Find Interesting ACL" },
{ value: "Find Workstations where Domain Users can RDP", text: "Find Workstations where Domain Users can RDP" },
{ value: "Find LAPS Enabled Workstations", text: "Find LAPS Enabled Workstations" }
];
var PreBuiltQuery = document.getElementById("PreBuilt-Mode");
populateDropdownOptions(PreBuiltQuery, options);
PreBuiltQuery.value = "Please Select";
PreBuiltQuery.addEventListener("change", SetLDAP);
}
// Populate dropdown option for the condition
function ConditionOptions(value) {
var conditionOptions = [
{ value: "", text: "Please Select" },
{ value: "&", text: "AND" },
{ value: "|", text: "OR" },
{ value: "!", text: "NOT" },
{ value: "END", text: "NO CONDITION"}
];
if (value === 1) {
//clear all the dropdown value before populating
var Condition1Option = document.getElementById("Condition1");
var Condition2Option = document.getElementById("Condition2");
var Condition3Option = document.getElementById("Condition3");
populateDropdownOptions(Condition1Option, [],true);
//populateDropdownOptions(Condition2Option, [],true);
//populateDropdownOptions(Condition3Option, [],true);
//Populate with the dropdown options
populateDropdownOptions(Condition1Option, conditionOptions);
populateDropdownOptions(Condition2Option, conditionOptions);
populateDropdownOptions(Condition3Option, conditionOptions);
Condition1Option.value = ""; // Set the initial selected option to empty value
Condition1Option.classList.add("centered-option"); // Add CSS class to center the selected option
}
else if (value === 2) {
var Condition1Option = document.getElementById("Condition1");
var Condition2Option = document.getElementById("Condition2");
var Condition3Option = document.getElementById("Condition3");
//populateDropdownOptions(Condition1Option, [],true);
populateDropdownOptions(Condition2Option, [],true);
populateDropdownOptions(Condition3Option, [],true);
//Populate with the dropdown options
//populateDropdownOptions(Condition1Option, conditionOptions);
populateDropdownOptions(Condition2Option, conditionOptions);
populateDropdownOptions(Condition3Option, conditionOptions);
//Condition1Option.value = ""; // Set the initial selected option to empty value
Condition2Option.value = "";
Condition1Option.classList.add("centered-option"); // Add CSS class to center the selected option
Condition2Option.classList.add("centered-option"); // Add CSS class to center the selected option
}
else if (value === 3) {
var Condition1Option = document.getElementById("Condition1");
var Condition2Option = document.getElementById("Condition2");
var Condition3Option = document.getElementById("Condition3");
//populateDropdownOptions(Condition1Option, [],true);
//populateDropdownOptions(Condition2Option, [],true);
populateDropdownOptions(Condition3Option, [],true);
//Populate with the dropdown options
populateDropdownOptions(Condition1Option, conditionOptions);
populateDropdownOptions(Condition2Option, conditionOptions);
populateDropdownOptions(Condition3Option, conditionOptions);
//Condition1Option.value = ""; // Set the initial selected option to empty value
//Condition2Option.value = "";
Condition3Option.value = "";
Condition1Option.classList.add("centered-option"); // Add CSS class to center the selected option
Condition2Option.classList.add("centered-option"); // Add CSS class to center the selected option
Condition3Option.classList.add("centered-option"); // Add CSS class to center the selected option
}
}
// Populate dropdown option for the Attributes in Custom Query Builder Page
function AttributesCustomPage() {
// Get the checkboxes and the select elements
const objectCategoryCheckboxes = document.querySelectorAll("#Custom .form-check-input");
const attributeSelects = document.querySelectorAll("#Custom .attribute-column select");
// Define the attribute options for each object class
const attributeOptions = {
user: ["name", "givenName", "sn","sAMAccountName","description","countryCode","objectSid","memberOf","servicePrincipalName","badPwdCount","logonCount","adminCount","userAccountControl","isCriticalSystemObject"],
computer: ["name", "sAMAccountName", "dNSHostName","countryCode","objectGUID","objectSid","operatingSystem","badPwdCount","isCriticalSystemObject"],
group: ["sAMAccountName", "description", "objectGUID","objectSid","member","memberOf","adminCount","isCriticalSystemObject"],
};
// Function to update the attribute options based on the selected object classes
function updateAttributeOptions() {
// Reset the attribute options
attributeSelects.forEach((select) => {
select.innerHTML = "<option value=''>Please Select</option>";
});
// Get the selected object classes
const selectedObjectCategories = Array.from(objectCategoryCheckboxes)
.filter((checkbox) => checkbox.checked)
.map((checkbox) => checkbox.id);
// Add disabled options as group headers
selectedObjectCategories.forEach((objectCategory) => {
const groupHeader = document.createElement("option");
groupHeader.value = "";
groupHeader.textContent = objectCategory;
groupHeader.disabled = true;
attributeSelects.forEach((select) => {
select.appendChild(groupHeader.cloneNode(true));
});
// Add attributes to the select elements
attributeOptions[objectCategory].forEach((attribute) => {
attributeSelects.forEach((select) => {
const option = document.createElement("option");
option.value = attribute;
option.textContent = attribute;
select.appendChild(option);
});
});
});
}
// Add event listener to the checkboxes
objectCategoryCheckboxes.forEach((checkbox) => {
checkbox.addEventListener("change", updateAttributeOptions);
});
}
// Call the function with the desired value to populate and center the dropdowns
function populateDropdownOptions(selectElement, options, clearOptions = false) {
if (clearOptions) {
// Clear existing options
selectElement.innerHTML = "";
}
// Create new options
options.forEach(function (option) {
const optionElement = document.createElement("option");
optionElement.value = option.value;
optionElement.textContent = option.text;
selectElement.appendChild(optionElement);
});
}
function SwitchColorMode() {
if (document.documentElement.getAttribute('data-bs-theme') === 'dark') {
document.documentElement.setAttribute('data-bs-theme', 'light');
var elements = document.querySelectorAll(".dark");
for (var i = 0; i < elements.length; i++) {
elements[i].classList.remove("dark");
elements[i].classList.add("light");
}
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light'); //add this
document.getElementById("Switch-Color").innerHTML = " Dark Mode";
} else {
document.documentElement.setAttribute('data-bs-theme', 'dark');
var elements = document.querySelectorAll(".light");
for (var i = 0; i < elements.length; i++) {
elements[i].classList.remove("light");
elements[i].classList.add("dark");
}
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark'); //add this
document.getElementById("Switch-Color").innerHTML = " Light Mode";
}
}
function disableElements(value) {
const attribute1Select = document.getElementById("Attribute1");
const attribute2Select = document.getElementById("Attribute2");
const attribute3Select = document.getElementById("Attribute3");
const searchValue1Input = document.getElementById("SearchValue1");
const searchValue2Input = document.getElementById("SearchValue2");
const searchValue3Input = document.getElementById("SearchValue3");
const condition1Select = document.getElementById("Condition1");
const condition2Select = document.getElementById("Condition2");
const condition3Select = document.getElementById("Condition3");
if (value === 1) {
attribute1Select.disabled = false;
searchValue1Input.disabled = false;
condition1Select.disabled = false;
attribute2Select.disabled = true;
searchValue2Input.disabled = true;
condition2Select.disabled = true;
attribute3Select.disabled = true;
searchValue3Input.disabled = true;
condition3Select.disabled = true;
}
else if (value === 2) {
attribute1Select.disabled = false;
searchValue1Input.disabled = false;
condition1Select.disabled = false;
attribute2Select.disabled = false;
searchValue2Input.disabled = false;
condition2Select.disabled = false;
attribute3Select.disabled = true;
searchValue3Input.disabled = true;
condition3Select.disabled = true;
}
else if (value === 3) {
attribute1Select.disabled = false;
searchValue1Input.disabled = false;
condition1Select.disabled = false;
attribute2Select.disabled = false;
searchValue2Input.disabled = false;
condition2Select.disabled = false;
attribute3Select.disabled = false;
searchValue3Input.disabled = false;
condition3Select.disabled = false;
}
// Apply styles to disabled elements
applyDisabledStyles();
}
function applyDisabledStyles() {
const disabledElements = document.querySelectorAll("select:disabled, input:disabled");
const enabledElements = document.querySelectorAll("select:not(:disabled), input:not(:disabled)");
disabledElements.forEach(function (element) {
element.style.backgroundColor = "#f5f5f5"; // Change to desired grey color
element.style.color = "#777"; // Change to desired text color
});
enabledElements.forEach(function (element) {
element.style.backgroundColor = ""; // Reset element background color
element.style.color = ""; // Reset element text color
});
}
// Call the function to disable elements and apply styles
//Function for the Custom Query Builder Page
//Additional Attributes Count + AND -
function AttributeCount() {
const plus = document.querySelector(".plus-btn");
const minus = document.querySelector(".minus-btn");
const num = document.querySelector(".num");
let a = 1;
disableElements(a);
//triggered when plus icon is clicked
plus.addEventListener("click", () => {
if (a < 3) {
a++;
num.value = a;
disableElements(a);
ConditionOptions(a);
}
});
//triggered when minus icon is clicked
minus.addEventListener("click", () => {
if (a > 1) {
a--;
num.value = a;
disableElements(a);
ConditionOptions(a);
}
});
}
function CustomBuilderConditionTrigger(attributeSelect) {
document.getElementById("Condition1").addEventListener("change", function() {
var attribute1 = document.getElementById("Attribute1").value;
var searchvalue1 = document.getElementById("SearchValue1").value;
var condition1 = document.getElementById("Condition1").value;
var objectCategory_Value;
const objectCategoryCheckboxes = document.querySelectorAll("#Custom .form-check-input");
const selectedObjectCategory = Array.from(objectCategoryCheckboxes)
.filter((checkbox) => checkbox.checked)
.map((checkbox) => checkbox.id);
objectCategory_Value=selectedObjectCategory[0];
if (condition1==="!"){
//alert(condition1);
updatedisplay(condition1);
}
else if (condition1==="END") {
//alert(condition1);
updatedisplay(condition1);
}
function updatedisplay(condition){
// IP address
var ip = document.getElementById("LDAP_IP").value;
var port = document.getElementById("LDAP_PORT").value;
var domain = document.getElementById("Domain").value; //use this for ADSearch
//Break Domain into parts for LDAPSearch.
var domain_array = domain.split(".")
//Find length of array if subdomain involved. Need 3 parts
if (domain_array.length===3){
var domain_part1 = domain_array[0];
var domain_part2 = domain_array[1];
var domain_part3 = domain_array[2];
}
else if (domain_array.length===2){
var domain_part1 = domain_array[0];
var domain_part2 = domain_array[1];
}
if (domain_array.length===3){
if (condition==="!") {
ldap_query = "(&(objectCategory="+objectCategory_Value+")"+"("+attribute1+condition1+"="+searchvalue1+"))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command_Custom").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command_Custom").value = LDAPSearch_Command;
document.getElementById("RAW_Command_Custom").value = RAW_Command;
}
else if (condition==="END") {
ldap_query = "(&(objectCategory="+objectCategory_Value+")"+"("+attribute1+"="+searchvalue1+"))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+",DC="+domain_part3+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command_Custom").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command_Custom").value = LDAPSearch_Command;
document.getElementById("RAW_Command_Custom").value = RAW_Command;
}
}
else if (domain_array.length===2){
if (condition==="!") {
ldap_query = "(&(objectCategory="+objectCategory_Value+")"+"("+attribute1+condition1+"="+searchvalue1+"))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command_Custom").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command_Custom").value = LDAPSearch_Command;
document.getElementById("RAW_Command_Custom").value = RAW_Command;
}
else if (condition==="END") {
ldap_query = "(&(objectCategory="+objectCategory_Value+")"+"("+attribute1+"="+searchvalue1+"))";
var ADSearch_Command = "ADSearch.exe --domain " +domain+" --search \""+ldap_query+"\"";
var LDAPSearch_Command = "ldapsearch -x -h " +ip+" -p "+port+" -b \""+"DC="+domain_part1+",DC="+domain_part2+"\" "+"\""+ldap_query+"\"";
var RAW_Command = ldap_query;
document.getElementById("ADSearch_Command_Custom").value = ADSearch_Command;
document.getElementById("LDAPSearch_Command_Custom").value = LDAPSearch_Command;
document.getElementById("RAW_Command_Custom").value = RAW_Command;
}
}
}
});
//END of Condition 1 Trigger Update Value
document.getElementById("Condition2").addEventListener("change", function() {
var attribute1 = document.getElementById("Attribute1").value;
var searchvalue1 = document.getElementById("SearchValue1").value;
var condition1 = document.getElementById("Condition1").value;
var attribute2 = document.getElementById("Attribute2").value;
var searchvalue2 = document.getElementById("SearchValue2").value;
var condition2 = document.getElementById("Condition2").value;
var objectCategory_Value;
const objectCategoryCheckboxes = document.querySelectorAll("#Custom .form-check-input");
const selectedObjectCategory = Array.from(objectCategoryCheckboxes)
.filter((checkbox) => checkbox.checked)
.map((checkbox) => checkbox.id);
objectCategory_Value=selectedObjectCategory[0];
updatedisplay(condition1,condition2);
function updatedisplay(condition1,condition2){
// IP address
var ip = document.getElementById("LDAP_IP").value;
var port = document.getElementById("LDAP_PORT").value;
var domain = document.getElementById("Domain").value; //use this for ADSearch
//Break Domain into parts for LDAPSearch.
var domain_array = domain.split(".")
//Find length of array if subdomain involved. Need 3 parts
if (domain_array.length===3){
var domain_part1 = domain_array[0];
var domain_part2 = domain_array[1];
var domain_part3 = domain_array[2];
}
else if (domain_array.length===2){
var domain_part1 = domain_array[0];