-
Notifications
You must be signed in to change notification settings - Fork 155
/
windows-privesc-check.py
3208 lines (2912 loc) · 133 KB
/
windows-privesc-check.py
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
# Licence
# =======
#
# windows-privesc-check - Security Auditing Tool For Windows
# Copyright (C) 2010 [email protected]
# http://pentestmonkey.net/windows-privesc-check
#
# This tool may be used for legal purposes only. Users take full responsibility
# for any actions performed using this tool. The author accepts no liability for
# damage caused by this tool. If these terms are not acceptable to you, then you
# may not use this tool.
#
# In all other respects the GPL version 2 applies.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# TODO List
# =========
#
# TODO review "read" perms. should probably ignore these.
# TODO explaination of what various permissions mean
# TODO Audit: Process listing, full paths and perms of all processes
# TODO dlls used by programs (for all checks)
# TODO find web roots and check for write access
# TODO support remote server (remote file, reg keys, unc paths for file, remote resolving of sids)
# TODO task scheduler
# TODO alert if lanman hashes are being stored (for post-exploitation)
# TODO alert if named local/domain service accounts are being used (for post-exploitation)
# TODO Alert if really important patches are missing. These are metasploitable:
# MS10_015 977165 Vulnerabilities in Windows Kernel Could Allow Elevation of Privilege (kitrap0d - meterpreter "getsystem")
# MS03_049 828749 Microsoft Workstation Service NetAddAlternateComputerName Overflow (netapi)
# MS04_007 828028 Microsoft ASN.1 Library Bitstring Heap Overflow (killbill)
# MS04_011 835732 Microsoft LSASS Service DsRolerUpgradeDownlevelServer Overflow (lsass)
# MS04_031 841533 Microsoft NetDDE Service Overflow (netdde)
# MS05_039 899588 Microsoft Plug and Play Service Overflow (pnp)
# MS06_025 911280 Microsoft RRAS Service RASMAN Registry Overflow (rasmans_reg)
# MS06_025 911280 Microsoft RRAS Service Overflow (rras)
# MS06_040 921883 Microsoft Server Service NetpwPathCanonicalize Overflow (netapi)
# MS06_066 923980 Microsoft Services MS06-066 nwapi32.dll (nwapi)
# MS06_066 923980 Microsoft Services MS06-066 nwwks.dll (nwwks)
# MS06_070 924270 Microsoft Workstation Service NetpManageIPCConnect Overflow (wkssvc)
# MS07_029 935966 Microsoft DNS RPC Service extractQuotedChar() Overflow (SMB) (msdns_zonename)
# MS08_067 958644 Microsoft Server Service Relative Path Stack Corruption (netapi)
# MS09_050 975517 Microsoft SRV2.SYS SMB Negotiate ProcessID Function Table Dereference (smb2_negotiate_func_index)
# MS03_026 823980 Microsoft RPC DCOM Interface Overflow
# MS05_017 892944 Microsoft Message Queueing Service Path Overflow
# MS07_065 937894 Microsoft Message Queueing Service DNS Name Path Overflow
# TODO registry key checks for windows services
# TODO per-user checks including perms on home dirs and startup folders + default user and all users
# TODO need to be able to order issues more logically. Maybe group by section?
# Building an Executable
# ======================
#
# This script should be converted to an exe before it is used for
# auditing - otherwise you'd have to install loads of dependencies
# on the target system.
#
# Download pyinstaller: http://www.pyinstaller.org/changeset/latest/trunk?old_path=%2F&format=zip
# Read the docs: http://www.pyinstaller.org/export/latest/tags/1.4/doc/Manual.html?format=raw
#
# Unzip to c:\pyinstaller (say)
# cd c:\pyinstaller
# python Configure.py
# python Makespec.py --onefile c:\somepath\wpc.py
# python Build.py wpc\wpc.spec
# wpc\dist\wpc.exe
#
# Alternative to pyinstaller is cxfreeze. This doesn't always work, though:
# \Python26\Scripts\cxfreeze wpc.py --target-dir dist
# zip -r wpc.zip dist
#
# You then need to copy wpc.zip to the target and unzip it. The exe therein
# should then run because all the dependencies are in the current (dist) directory.
# 64-bit vs 32-bit
# ================
#
# If we run a 32-bit version of this script on a 64-bit box we have (at least) the
# following problems:
# * Registry: We CAN'T see the whole 64-bit registry. This seems insurmountable.
# * Files: It's harder to see in system32. This can be worked round.
# What types of object have permissions?
# ======================================
#
# Files, directories and registry keys are the obvious candidates. There are several others too...
#
# This provides a good summary: http://msdn.microsoft.com/en-us/library/aa379557%28v=VS.85%29.aspx
#
# Files or directories on an NTFS file system GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
# Named pipes
# Anonymous pipes
# Processes
# Threads
# File-mapping objects
# Access tokens
# Window-management objects (window stations and desktops)
# Registry keys
# Windows services
# Local or remote printers
# Network shares
# Interprocess synchronization objects
# Directory service objects
#
# This provides a good description of how Access Tokens interact with the Security Descriptors on Securable Objects: http://msdn.microsoft.com/en-us/library/aa374876%28v=VS.85%29.aspx
#
# http://msdn.microsoft.com/en-us/library/aa379593(VS.85).aspx
# win32security.SE_UNKNOWN_OBJECT_TYPE - n/a
# win32security.SE_FILE_OBJECT - poc working
# win32security.SE_SERVICE - poc working
# win32security.SE_PRINTER - TODO Indicates a printer. A printer object can be a local printer, such as PrinterName, or a remote printer, such as
# \\ComputerName\PrinterName.
# win32security.SE_REGISTRY_KEY - TODO
# Indicates a registry key. A registry key object can be in the local registry, such as CLASSES_ROOT\SomePath or in a remote registry,
# such as \\ComputerName\CLASSES_ROOT\SomePath.
# The names of registry keys must use the following literal strings to identify the predefined registry keys:
# "CLASSES_ROOT", "CURRENT_USER", "MACHINE", and "USERS".
# perms: http://msdn.microsoft.com/en-us/library/ms724878(VS.85).aspx
# win32security.SE_LMSHARE - TODO Indicates a network share. A share object can be local, such as ShareName, or remote, such as \\ComputerName\ShareName.
# win32security.SE_KERNEL_OBJECT - TODO
# Indicates a local kernel object.
# The GetSecurityInfo and SetSecurityInfo functions support all types of kernel objects.
# The GetNamedSecurityInfo and SetNamedSecurityInfo functions work only with the following kernel objects:
# semaphore, event, mutex, waitable timer, and file mapping.
# win32security.SE_WINDOW_OBJECT - TODO Indicates a window station or desktop object on the local computer.
# You cannot use GetNamedSecurityInfo and SetNamedSecurityInfo with these objects because the names of window stations or desktops are not unique.
# win32security.SE_DS_OBJECT - TODO - Active Directory object
# Indicates a directory service object or a property set or property of a directory service object.
# The name string for a directory service object must be in X.500 form, for example:
# CN=SomeObject,OU=ou2,OU=ou1,DC=DomainName,DC=CompanyName,DC=com,O=internet
# perm list: http://msdn.microsoft.com/en-us/library/aa772285(VS.85).aspx
# win32security.SE_DS_OBJECT_ALL - TODO
# Indicates a directory service object and all of its property sets and properties.
# win32security.SE_PROVIDER_DEFINED_OBJECT - TODO Indicates a provider-defined object.
# win32security.SE_WMIGUID_OBJECT - TODO Indicates a WMI object.
# win32security.SE_REGISTRY_WOW64_32KEY - TODO Indicates an object for a registry entry under WOW64.
# What sort of privileges can be granted on Windows?
# ==================================================
#
# These are bit like Capabilities on Linux.
# http://msdn.microsoft.com/en-us/library/bb530716(VS.85).aspx
# http://msdn.microsoft.com/en-us/library/bb545671(VS.85).aspx
#
# These privs sound like they might allow the holder to gain admin rights:
#
# SE_ASSIGNPRIMARYTOKEN_NAME TEXT("SeAssignPrimaryTokenPrivilege") Required to assign the primary token of a process. User Right: Replace a process-level token.
# SE_BACKUP_NAME TEXT("SeBackupPrivilege") Required to perform backup operations. This privilege causes the system to grant all read access control to any file, regardless of the access control list (ACL) specified for the file. Any access request other than read is still evaluated with the ACL. This privilege is required by the RegSaveKey and RegSaveKeyExfunctions. The following access rights are granted if this privilege is held: READ_CONTROL ACCESS_SYSTEM_SECURITY FILE_GENERIC_READ FILE_TRAVERSE User Right: Back up files and directories.
# SE_CREATE_PAGEFILE_NAME TEXT("SeCreatePagefilePrivilege") Required to create a paging file. User Right: Create a pagefile.
# SE_CREATE_TOKEN_NAME TEXT("SeCreateTokenPrivilege") Required to create a primary token. User Right: Create a token object.
# SE_DEBUG_NAME TEXT("SeDebugPrivilege") Required to debug and adjust the memory of a process owned by another account. User Right: Debug programs.
# SE_ENABLE_DELEGATION_NAME TEXT("SeEnableDelegationPrivilege") Required to mark user and computer accounts as trusted for delegation. User Right: Enable computer and user accounts to be trusted for delegation.
# SE_LOAD_DRIVER_NAME TEXT("SeLoadDriverPrivilege") Required to load or unload a device driver. User Right: Load and unload device drivers.
# SE_MACHINE_ACCOUNT_NAME TEXT("SeMachineAccountPrivilege") Required to create a computer account. User Right: Add workstations to domain.
# SE_MANAGE_VOLUME_NAME TEXT("SeManageVolumePrivilege") Required to enable volume management privileges. User Right: Manage the files on a volume.
# SE_RELABEL_NAME TEXT("SeRelabelPrivilege") Required to modify the mandatory integrity level of an object. User Right: Modify an object label.
# SE_RESTORE_NAME TEXT("SeRestorePrivilege") Required to perform restore operations. This privilege causes the system to grant all write access control to any file, regardless of the ACL specified for the file. Any access request other than write is still evaluated with the ACL. Additionally, this privilege enables you to set any valid user or group SID as the owner of a file. This privilege is required by the RegLoadKey function. The following access rights are granted if this privilege is held: WRITE_DAC WRITE_OWNER ACCESS_SYSTEM_SECURITY FILE_GENERIC_WRITE FILE_ADD_FILE FILE_ADD_SUBDIRECTORY DELETE User Right: Restore files and directories.
# SE_SHUTDOWN_NAME TEXT("SeShutdownPrivilege") Required to shut down a local system. User Right: Shut down the system.
# SE_SYNC_AGENT_NAME TEXT("SeSyncAgentPrivilege") Required for a domain controller to use the LDAP directory synchronization services. This privilege enables the holder to read all objects and properties in the directory, regardless of the protection on the objects and properties. By default, it is assigned to the Administrator and LocalSystem accounts on domain controllers. User Right: Synchronize directory service data.
# SE_TAKE_OWNERSHIP_NAME TEXT("SeTakeOwnershipPrivilege") Required to take ownership of an object without being granted discretionary access. This privilege allows the owner value to be set only to those values that the holder may legitimately assign as the owner of an object. User Right: Take ownership of files or other objects.
# SE_TCB_NAME TEXT("SeTcbPrivilege") This privilege identifies its holder as part of the trusted computer base. Some trusted protected subsystems are granted this privilege. User Right: Act as part of the operating system.
# SE_TRUSTED_CREDMAN_ACCESS_NAME TEXT("SeTrustedCredManAccessPrivilege") Required to access Credential Manager as a trusted caller. User Right: Access Credential Manager as a trusted caller.
#
# These sound like they could be troublesome in the wrong hands:
#
# SE_SECURITY_NAME TEXT("SeSecurityPrivilege") Required to perform a number of security-related functions, such as controlling and viewing audit messages. This privilege identifies its holder as a security operator. User Right: Manage auditing and security log.
# SE_REMOTE_SHUTDOWN_NAME TEXT("SeRemoteShutdownPrivilege") Required to shut down a system using a network request. User Right: Force shutdown from a remote system.
# SE_PROF_SINGLE_PROCESS_NAME TEXT("SeProfileSingleProcessPrivilege") Required to gather profiling information for a single process. User Right: Profile single process.
# SE_AUDIT_NAME TEXT("SeAuditPrivilege") Required to generate audit-log entries. Give this privilege to secure servers.User Right: Generate security audits.
# SE_INC_BASE_PRIORITY_NAME TEXT("SeIncreaseBasePriorityPrivilege") Required to increase the base priority of a process. User Right: Increase scheduling priority.
# SE_INC_WORKING_SET_NAME TEXT("SeIncreaseWorkingSetPrivilege") Required to allocate more memory for applications that run in the context of users. User Right: Increase a process working set.
# SE_INCREASE_QUOTA_NAME TEXT("SeIncreaseQuotaPrivilege") Required to increase the quota assigned to a process. User Right: Adjust memory quotas for a process.
# SE_LOCK_MEMORY_NAME TEXT("SeLockMemoryPrivilege") Required to lock physical pages in memory. User Right: Lock pages in memory.
# SE_SYSTEM_ENVIRONMENT_NAME TEXT("SeSystemEnvironmentPrivilege") Required to modify the nonvolatile RAM of systems that use this type of memory to store configuration information. User Right: Modify firmware environment values.
#
# These sound less interesting:
#
# SE_CHANGE_NOTIFY_NAME TEXT("SeChangeNotifyPrivilege") Required to receive notifications of changes to files or directories. This privilege also causes the system to skip all traversal access checks. It is enabled by default for all users. User Right: Bypass traverse checking.
# SE_CREATE_GLOBAL_NAME TEXT("SeCreateGlobalPrivilege") Required to create named file mapping objects in the global namespace during Terminal Services sessions. This privilege is enabled by default for administrators, services, and the local system account.User Right: Create global objects. Windows XP/2000: This privilege is not supported. Note that this value is supported starting with Windows Server 2003, Windows XP with SP2, and Windows 2000 with SP4.
# SE_CREATE_PERMANENT_NAME TEXT("SeCreatePermanentPrivilege") Required to create a permanent object. User Right: Create permanent shared objects.
# SE_CREATE_SYMBOLIC_LINK_NAME TEXT("SeCreateSymbolicLinkPrivilege") Required to create a symbolic link. User Right: Create symbolic links.
# SE_IMPERSONATE_NAME TEXT("SeImpersonatePrivilege") Required to impersonate. User Right: Impersonate a client after authentication. Windows XP/2000: This privilege is not supported. Note that this value is supported starting with Windows Server 2003, Windows XP with SP2, and Windows 2000 with SP4.
# SE_SYSTEM_PROFILE_NAME TEXT("SeSystemProfilePrivilege") Required to gather profiling information for the entire system. User Right: Profile system performance.
# SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege") Required to modify the system time. User Right: Change the system time.
# SE_TIME_ZONE_NAME TEXT("SeTimeZonePrivilege") Required to adjust the time zone associated with the computer's internal clock. User Right: Change the time zone.
# SE_UNDOCK_NAME TEXT("SeUndockPrivilege") Required to undock a laptop. User Right: Remove computer from docking station.
# SE_UNSOLICITED_INPUT_NAME TEXT("SeUnsolicitedInputPrivilege") Required to read unsolicited input from a terminal device. User Right: Not applicable.
# These are from ntsecapi.h:
#
# SE_BATCH_LOGON_NAME TEXT("SeBatchLogonRight") Required for an account to log on using the batch logon type.
# SE_DENY_BATCH_LOGON_NAME TEXT("SeDenyBatchLogonRight") Explicitly denies an account the right to log on using the batch logon type.
# SE_DENY_INTERACTIVE_LOGON_NAME TEXT("SeDenyInteractiveLogonRight") Explicitly denies an account the right to log on using the interactive logon type.
# SE_DENY_NETWORK_LOGON_NAME TEXT("SeDenyNetworkLogonRight") Explicitly denies an account the right to log on using the network logon type.
# SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME TEXT("SeDenyRemoteInteractiveLogonRight") Explicitly denies an account the right to log on remotely using the interactive logon type.
# SE_DENY_SERVICE_LOGON_NAME TEXT("SeDenyServiceLogonRight") Explicitly denies an account the right to log on using the service logon type.
# SE_INTERACTIVE_LOGON_NAME TEXT("SeInteractiveLogonRight") Required for an account to log on using the interactive logon type.
# SE_NETWORK_LOGON_NAME TEXT("SeNetworkLogonRight") Required for an account to log on using the network logon type.
# SE_REMOTE_INTERACTIVE_LOGON_NAME TEXT("SeRemoteInteractiveLogonRight") Required for an account to log on remotely using the interactive logon type.
# SE_SERVICE_LOGON_NAME TEXT("SeServiceLogonRight") Required for an account to log on using the service logon type.
#import pythoncom, sys, os, time, win32api
#from win32com.taskscheduler import taskscheduler
import glob
import datetime
import socket
import os, sys
import win32process
import re
import win32security, ntsecuritycon, win32api, win32con, win32file
import win32service
import pywintypes # doesn't play well with molebox pro - why did we need this anyway?
import win32net
import ctypes
import getopt
import _winreg
import win32netcon
from subprocess import Popen, PIPE, STDOUT
# from winapi import *
from ntsecuritycon import TokenSessionId, TokenSandBoxInert, TokenType, TokenImpersonationLevel, TokenVirtualizationEnabled, TokenVirtualizationAllowed, TokenHasRestrictions, TokenElevationType, TokenUIAccess, TokenUser, TokenOwner, TokenGroups, TokenRestrictedSids, TokenPrivileges, TokenPrimaryGroup, TokenSource, TokenDefaultDacl, TokenStatistics, TokenOrigin, TokenLinkedToken, TokenLogonSid, TokenElevation, TokenIntegrityLevel, TokenMandatoryPolicy, SE_ASSIGNPRIMARYTOKEN_NAME, SE_BACKUP_NAME, SE_CREATE_PAGEFILE_NAME, SE_CREATE_TOKEN_NAME, SE_DEBUG_NAME, SE_LOAD_DRIVER_NAME, SE_MACHINE_ACCOUNT_NAME, SE_RESTORE_NAME, SE_SHUTDOWN_NAME, SE_TAKE_OWNERSHIP_NAME, SE_TCB_NAME
# Need: SE_ENABLE_DELEGATION_NAME, SE_MANAGE_VOLUME_NAME, SE_RELABEL_NAME, SE_SYNC_AGENT_NAME, SE_TRUSTED_CREDMAN_ACCESS_NAME
k32 = ctypes.windll.kernel32
wow64 = ctypes.c_long( 0 )
on64bitwindows = 1
remote_server = None
remote_username = None
remote_password = None
remote_domain = None
local_ips = socket.gethostbyname_ex(socket.gethostname())[2] # have to do this before Wow64DisableWow64FsRedirection
version = "1.0"
svnversion="$Revision: 24 $" # Don't change this line. Auto-updated.
svnnum=re.sub('[^0-9]', '', svnversion)
if svnnum:
version = version + "svn" + svnnum
all_checks = 0
registry_checks = 0
path_checks = 0
service_checks = 0
service_audit = 0
drive_checks = 0
eventlog_checks = 0
progfiles_checks = 0
process_checks = 0
share_checks = 0
passpol_audit = 0
user_group_audit = 0
logged_in_audit = 0
process_audit = 0
admin_users_audit= 0
host_info_audit = 0
ignore_trusted = 0
owner_info = 0
weak_perms_only = 0
host_info_audit = 0
patch_checks = 0
verbose = 0
report_file_name = None
kb_nos = {
'977165': 'MS10_015 Vulnerabilities in Windows Kernel Could Allow Elevation of Privilege (kitrap0d - meterpreter "getsystem")',
'828749': 'MS03_049 Microsoft Workstation Service NetAddAlternateComputerName Overflow (netapi) ',
'828028': 'MS04_007 Microsoft ASN.1 Library Bitstring Heap Overflow (killbill) ',
'835732': 'MS04_011 Microsoft LSASS Service DsRolerUpgradeDownlevelServer Overflow (lsass) ',
'841533': 'MS04_031 Microsoft NetDDE Service Overflow (netdde)',
'899588': 'MS05_039 Microsoft Plug and Play Service Overflow (pnp)',
'911280': 'MS06_025 Microsoft RRAS Service RASMAN Registry Overflow (rasmans_reg)',
'911280': 'MS06_025 Microsoft RRAS Service Overflow (rras)',
'921883': 'MS06_040 Microsoft Server Service NetpwPathCanonicalize Overflow (netapi)',
'923980': 'MS06_066 Microsoft Services MS06-066 nwapi32.dll (nwapi)',
'923980': 'MS06_066 Microsoft Services MS06-066 nwwks.dll (nwwks)',
'924270': 'MS06_070 Microsoft Workstation Service NetpManageIPCConnect Overflow (wkssvc)',
'935966': 'MS07_029 Microsoft DNS RPC Service extractQuotedChar() Overflow (SMB) (msdns_zonename)',
'958644': 'MS08_067 Microsoft Server Service Relative Path Stack Corruption (netapi)',
'975517': 'MS09_050 Microsoft SRV2.SYS SMB Negotiate ProcessID Function Table Dereference (smb2_negotiate_func_index)',
'823980': 'MS03_026 Microsoft RPC DCOM Interface Overflow',
'892944': 'MS05_017 Microsoft Message Queueing Service Path Overflow',
'937894': 'MS07_065 Microsoft Message Queueing Service DNS Name Path Overflow'
}
reg_paths = (
'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services',
'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run',
'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run',
'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce',
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run',
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell',
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit',
'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce',
'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce',
'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices',
'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce',
'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServices',
'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce',
'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows',
)
# We don't care if some users / groups hold dangerous permission because they're trusted
# These have fully qualified names:
trusted_principles_fq = (
"BUILTIN\\Administrators",
"NT SERVICE\\TrustedInstaller",
"NT AUTHORITY\\SYSTEM"
)
# We may temporarily regard a user as trusted (e.g. if we're looking for writable
# files in a user's path, we do not care that he can write to his own path)
tmp_trusted_principles_fq = (
)
eventlog_key_hklm = 'SYSTEM\CurrentControlSet\Services\Eventlog'
# We don't care if members of these groups hold dangerous permission because they're trusted
# These have names without a domain:
trusted_principles = (
"Administrators",
"Domain Admins",
"Enterprise Admins",
)
# Windows privileges from
windows_privileges = (
"SeAssignPrimaryTokenPrivilege",
"SeBackupPrivilege",
"SeCreatePagefilePrivilege",
"SeCreateTokenPrivilege",
"SeDebugPrivilege",
"SeEnableDelegationPrivilege",
"SeLoadDriverPrivilege",
"SeMachineAccountPrivilege",
"SeManageVolumePrivilege",
"SeRelabelPrivilege",
"SeRestorePrivilege",
"SeShutdownPrivilege",
"SeSyncAgentPrivilege",
"SeTakeOwnershipPrivilege",
"SeTcbPrivilege",
"SeTrustedCredManAccessPrivilege",
"SeSecurityPrivilege",
"SeRemoteShutdownPrivilege",
"SeProfileSingleProcessPrivilege",
"SeAuditPrivilege",
"SeIncreaseBasePriorityPrivilege",
"SeIncreaseWorkingSetPrivilege",
"SeIncreaseQuotaPrivilege",
"SeLockMemoryPrivilege",
"SeSystemEnvironmentPrivilege",
"SeChangeNotifyPrivilege",
"SeCreateGlobalPrivilege",
"SeCreatePermanentPrivilege",
"SeCreateSymbolicLinkPrivilege",
"SeImpersonatePrivilege",
"SeSystemProfilePrivilege",
"SeSystemtimePrivilege",
"SeTimeZonePrivilege",
"SeUndockPrivilege",
"SeUnsolicitedInputPrivilege",
"SeBatchLogonRight",
"SeDenyBatchLogonRight",
"SeDenyInteractiveLogonRight",
"SeDenyNetworkLogonRight",
"SeDenyRemoteInteractiveLogonRight",
"SeDenyServiceLogonRight",
"SeInteractiveLogonRight",
"SeNetworkLogonRight",
"SeRemoteInteractiveLogonRight",
"SeServiceLogonRight"
)
share_types = (
"STYPE_IPC",
"STYPE_DISKTREE",
"STYPE_PRINTQ",
"STYPE_DEVICE",
)
sv_types = (
"SV_TYPE_WORKSTATION",
"SV_TYPE_SERVER",
"SV_TYPE_SQLSERVER",
"SV_TYPE_DOMAIN_CTRL",
"SV_TYPE_DOMAIN_BAKCTRL",
"SV_TYPE_TIME_SOURCE",
"SV_TYPE_AFP",
"SV_TYPE_NOVELL",
"SV_TYPE_DOMAIN_MEMBER",
"SV_TYPE_PRINTQ_SERVER",
"SV_TYPE_DIALIN_SERVER",
"SV_TYPE_XENIX_SERVER",
"SV_TYPE_NT",
"SV_TYPE_WFW",
"SV_TYPE_SERVER_MFPN",
"SV_TYPE_SERVER_NT",
"SV_TYPE_POTENTIAL_BROWSER",
"SV_TYPE_BACKUP_BROWSER",
"SV_TYPE_MASTER_BROWSER",
"SV_TYPE_DOMAIN_MASTER",
"SV_TYPE_SERVER_OSF",
"SV_TYPE_SERVER_VMS",
"SV_TYPE_WINDOWS",
"SV_TYPE_DFS",
"SV_TYPE_CLUSTER_NT",
"SV_TYPE_TERMINALSERVER", # missing from win32netcon.py
#"SV_TYPE_CLUSTER_VS_NT", # missing from win32netcon.py
"SV_TYPE_DCE",
"SV_TYPE_ALTERNATE_XPORT",
"SV_TYPE_LOCAL_LIST_ONLY",
"SV_TYPE_DOMAIN_ENUM"
)
win32netcon.SV_TYPE_TERMINALSERVER = 0x2000000
dangerous_perms_write = {
# http://www.tek-tips.com/faqs.cfm?fid
'share': {
ntsecuritycon: (
"FILE_READ_DATA", #
"FILE_WRITE_DATA",
"FILE_APPEND_DATA",
"FILE_READ_EA", #
"FILE_WRITE_EA",
"FILE_EXECUTE", #
"FILE_READ_ATTRIBUTES", #
"FILE_WRITE_ATTRIBUTES",
"DELETE",
"READ_CONTROL", #
"WRITE_DAC",
"WRITE_OWNER",
"SYNCHRONIZE", #
)
},
'file': {
ntsecuritycon: (
#"FILE_READ_DATA",
"FILE_WRITE_DATA",
"FILE_APPEND_DATA",
#"FILE_READ_EA",
"FILE_WRITE_EA",
#"FILE_EXECUTE",
#"FILE_READ_ATTRIBUTES",
"FILE_WRITE_ATTRIBUTES",
"DELETE",
#"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
#"SYNCHRONIZE",
)
},
# http://msdn.microsoft.com/en-us/library/ms724878(VS.85).aspx
# KEY_ALL_ACCESS: STANDARD_RIGHTS_REQUIRED KEY_QUERY_VALUE KEY_SET_VALUE KEY_CREATE_SUB_KEY KEY_ENUMERATE_SUB_KEYS KEY_NOTIFY KEY_CREATE_LINK
# KEY_CREATE_LINK (0x0020) Reserved for system use.
# KEY_CREATE_SUB_KEY (0x0004) Required to create a subkey of a registry key.
# KEY_ENUMERATE_SUB_KEYS (0x0008) Required to enumerate the subkeys of a registry key.
# KEY_EXECUTE (0x20019) Equivalent to KEY_READ.
# KEY_NOTIFY (0x0010) Required to request change notifications for a registry key or for subkeys of a registry key.
# KEY_QUERY_VALUE (0x0001) Required to query the values of a registry key.
# KEY_READ (0x20019) Combines the STANDARD_RIGHTS_READ, KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY values.
# KEY_SET_VALUE (0x0002) Required to create, delete, or set a registry value.
# KEY_WOW64_32KEY (0x0200) Indicates that an application on 64-bit Windows should operate on the 32-bit registry view. For more information, see Accessing an Alternate Registry View. This flag must be combined using the OR operator with the other flags in this table that either query or access registry values.
# Windows 2000: This flag is not supported.
# KEY_WOW64_64KEY (0x0100) Indicates that an application on 64-bit Windows should operate on the 64-bit registry view. For more information, see Accessing an Alternate Registry View.
# This flag must be combined using the OR operator with the other flags in this table that either query or access registry values.
# Windows 2000: This flag is not supported.
# KEY_WRITE (0x20006) Combines the STANDARD_RIGHTS_WRITE, KEY_SET_VALUE, and KEY_CREATE_SUB_KEY access rights.
# "STANDARD_RIGHTS_REQUIRED",
# "STANDARD_RIGHTS_WRITE",
# "STANDARD_RIGHTS_READ",
# "DELETE",
# "READ_CONTROL",
# "WRITE_DAC",
#"WRITE_OWNER",
'reg': {
_winreg: (
#"KEY_ALL_ACCESS", # Combines the STANDARD_RIGHTS_REQUIRED, KEY_QUERY_VALUE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, and KEY_CREATE_LINK access rights.
#"KEY_QUERY_VALUE", # GUI "Query Value"
"KEY_SET_VALUE", # GUI "Set Value". Required to create, delete, or set a registry value.
"KEY_CREATE_LINK", # GUI "Create Link". Reserved for system use.
"KEY_CREATE_SUB_KEY", # GUI "Create subkey"
# "KEY_ENUMERATE_SUB_KEYS", # GUI "Create subkeys"
# "KEY_NOTIFY", # GUI "Notify"
#"KEY_EXECUTE", # same as KEY_READ
#"KEY_READ",
#"KEY_WOW64_32KEY",
#"KEY_WOW64_64KEY",
# "KEY_WRITE", # Combines the STANDARD_RIGHTS_WRITE, KEY_SET_VALUE, and KEY_CREATE_SUB_KEY access rights.
),
ntsecuritycon: (
"DELETE", # GUI "Delete"
# "READ_CONTROL", # GUI "Read Control" - read security descriptor
"WRITE_DAC", # GUI "Write DAC"
"WRITE_OWNER", # GUI "Write Owner"
#"STANDARD_RIGHTS_REQUIRED",
#"STANDARD_RIGHTS_WRITE",
#"STANDARD_RIGHTS_READ",
)
},
'directory': {
ntsecuritycon: (
#"FILE_LIST_DIRECTORY",
"FILE_ADD_FILE",
"FILE_ADD_SUBDIRECTORY",
#"FILE_READ_EA",
"FILE_WRITE_EA",
#"FILE_TRAVERSE",
"FILE_DELETE_CHILD",
#"FILE_READ_ATTRIBUTES",
"FILE_WRITE_ATTRIBUTES",
"DELETE",
#"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
#"SYNCHRONIZE",
)
},
'service_manager': {
# For service manager
# http://msdn.microsoft.com/en-us/library/ms685981(VS.85).aspx
# SC_MANAGER_ALL_ACCESS (0xF003F) Includes STANDARD_RIGHTS_REQUIRED, in addition to all access rights in this table.
# SC_MANAGER_CREATE_SERVICE (0x0002) Required to call the CreateService function to create a service object and add it to the database.
# SC_MANAGER_CONNECT (0x0001) Required to connect to the service control manager.
# SC_MANAGER_ENUMERATE_SERVICE (0x0004) Required to call the EnumServicesStatusEx function to list the services that are in the database.
# SC_MANAGER_LOCK (0x0008) Required to call the LockServiceDatabase function to acquire a lock on the database.
# SC_MANAGER_MODIFY_BOOT_CONFIG (0x0020) Required to call the NotifyBootConfigStatus function.
# SC_MANAGER_QUERY_LOCK_STATUS (0x0010)Required to call the QueryServiceLockStatus function to retrieve the lock status information for the database.
win32service: (
"SC_MANAGER_ALL_ACCESS",
"SC_MANAGER_CREATE_SERVICE",
"SC_MANAGER_CONNECT",
"SC_MANAGER_ENUMERATE_SERVICE",
"SC_MANAGER_LOCK",
"SC_MANAGER_MODIFY_BOOT_CONFIG",
"SC_MANAGER_QUERY_LOCK_STATUS",
)
},
'service': {
# For services:
# http://msdn.microsoft.com/en-us/library/ms685981(VS.85).aspx
# SERVICE_ALL_ACCESS (0xF01FF) Includes STANDARD_RIGHTS_REQUIRED in addition to all access rights in this table.
# SERVICE_CHANGE_CONFIG (0x0002) Required to call the ChangeServiceConfig or ChangeServiceConfig2 function to change the service configuration. Because this grants the caller the right to change the executable file that the system runs, it should be granted only to administrators.
# SERVICE_ENUMERATE_DEPENDENTS (0x0008) Required to call the EnumDependentServices function to enumerate all the services dependent on the service.
# SERVICE_INTERROGATE (0x0080) Required to call the ControlService function to ask the service to report its status immediately.
# SERVICE_PAUSE_CONTINUE (0x0040) Required to call the ControlService function to pause or continue the service.
# SERVICE_QUERY_CONFIG (0x0001) Required to call the QueryServiceConfig and QueryServiceConfig2 functions to query the service configuration.
# SERVICE_QUERY_STATUS (0x0004) Required to call the QueryServiceStatusEx function to ask the service control manager about the status of the service.
# SERVICE_START (0x0010) Required to call the StartService function to start the service.
# SERVICE_STOP (0x0020) Required to call the ControlService function to stop the service.
# SERVICE_USER_DEFINED_CONTROL(0x0100) Required to call the ControlService function to specify a user-defined control code.
win32service: (
# "SERVICE_INTERROGATE",
# "SERVICE_QUERY_STATUS",
# "SERVICE_ENUMERATE_DEPENDENTS",
"SERVICE_ALL_ACCESS",
"SERVICE_CHANGE_CONFIG",
"SERVICE_PAUSE_CONTINUE",
# "SERVICE_QUERY_CONFIG",
"SERVICE_START",
"SERVICE_STOP",
# "SERVICE_USER_DEFINED_CONTROL", # TODO this is granted most of the time. Double check that's not a bad thing.
)
},
}
all_perms = {
'share': {
ntsecuritycon: (
"FILE_READ_DATA", #
"FILE_WRITE_DATA",
"FILE_APPEND_DATA",
"FILE_READ_EA", #
"FILE_WRITE_EA",
"FILE_EXECUTE", #
"FILE_READ_ATTRIBUTES", #
"FILE_WRITE_ATTRIBUTES",
"DELETE",
"READ_CONTROL", #
"WRITE_DAC",
"WRITE_OWNER",
"SYNCHRONIZE", #
)
},
'file': {
ntsecuritycon: (
"FILE_READ_DATA",
"FILE_WRITE_DATA",
"FILE_APPEND_DATA",
"FILE_READ_EA",
"FILE_WRITE_EA",
"FILE_EXECUTE",
"FILE_READ_ATTRIBUTES",
"FILE_WRITE_ATTRIBUTES",
"DELETE",
"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
"SYNCHRONIZE",
)
},
'reg': {
_winreg: (
"KEY_ALL_ACCESS",
"KEY_CREATE_LINK",
"KEY_CREATE_SUB_KEY",
"KEY_ENUMERATE_SUB_KEYS",
"KEY_EXECUTE",
"KEY_NOTIFY",
"KEY_QUERY_VALUE",
"KEY_READ",
"KEY_SET_VALUE",
"KEY_WOW64_32KEY",
"KEY_WOW64_64KEY",
"KEY_WRITE",
),
ntsecuritycon: (
"DELETE",
"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
"STANDARD_RIGHTS_REQUIRED",
"STANDARD_RIGHTS_WRITE",
"STANDARD_RIGHTS_READ",
"SYNCHRONIZE",
)
},
'directory': {
ntsecuritycon: (
"FILE_LIST_DIRECTORY",
"FILE_ADD_FILE",
"FILE_ADD_SUBDIRECTORY",
"FILE_READ_EA",
"FILE_WRITE_EA",
"FILE_TRAVERSE",
"FILE_DELETE_CHILD",
"FILE_READ_ATTRIBUTES",
"FILE_WRITE_ATTRIBUTES",
"DELETE",
"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
"SYNCHRONIZE",
)
},
'service_manager': {
win32service: (
"SC_MANAGER_ALL_ACCESS",
"SC_MANAGER_CREATE_SERVICE",
"SC_MANAGER_CONNECT",
"SC_MANAGER_ENUMERATE_SERVICE",
"SC_MANAGER_LOCK",
"SC_MANAGER_MODIFY_BOOT_CONFIG",
"SC_MANAGER_QUERY_LOCK_STATUS",
)
},
'service': {
win32service: (
"SERVICE_INTERROGATE",
"SERVICE_QUERY_STATUS",
"SERVICE_ENUMERATE_DEPENDENTS",
"SERVICE_ALL_ACCESS",
"SERVICE_CHANGE_CONFIG",
"SERVICE_PAUSE_CONTINUE",
"SERVICE_QUERY_CONFIG",
"SERVICE_START",
"SERVICE_STOP",
"SERVICE_USER_DEFINED_CONTROL", # TODO this is granted most of the time. Double check that's not a bad thing.
)
},
'process': {
win32con: (
"PROCESS_TERMINATE",
"PROCESS_CREATE_THREAD",
"PROCESS_VM_OPERATION",
"PROCESS_VM_READ",
"PROCESS_VM_WRITE",
"PROCESS_DUP_HANDLE",
"PROCESS_CREATE_PROCESS",
"PROCESS_SET_QUOTA",
"PROCESS_SET_INFORMATION",
"PROCESS_QUERY_INFORMATION",
"PROCESS_ALL_ACCESS"
),
ntsecuritycon: (
"DELETE",
"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
"SYNCHRONIZE",
"STANDARD_RIGHTS_REQUIRED",
"STANDARD_RIGHTS_READ",
"STANDARD_RIGHTS_WRITE",
"STANDARD_RIGHTS_EXECUTE",
"STANDARD_RIGHTS_ALL",
"SPECIFIC_RIGHTS_ALL",
"ACCESS_SYSTEM_SECURITY",
"MAXIMUM_ALLOWED",
"GENERIC_READ",
"GENERIC_WRITE",
"GENERIC_EXECUTE",
"GENERIC_ALL"
)
},
'thread': {
win32con: (
"THREAD_TERMINATE",
"THREAD_SUSPEND_RESUME",
"THREAD_GET_CONTEXT",
"THREAD_SET_CONTEXT",
"THREAD_SET_INFORMATION",
"THREAD_QUERY_INFORMATION",
"THREAD_SET_THREAD_TOKEN",
"THREAD_IMPERSONATE",
"THREAD_DIRECT_IMPERSONATION",
"THREAD_ALL_ACCESS",
"THREAD_QUERY_LIMITED_INFORMATION",
"THREAD_SET_LIMITED_INFORMATION"
),
ntsecuritycon: (
"DELETE",
"READ_CONTROL",
"WRITE_DAC",
"WRITE_OWNER",
"SYNCHRONIZE",
)
},
}
# Used to store a data structure representing the issues we've found
# We use this to generate the report
issues = {}
issue_template = {
'WPC001': {
'title': "Insecure Permissions on Program Files",
'description': '''Some of the programs in %ProgramFiles% and/or %ProgramFiles(x86)% could be changed by non-administrative users.
This could allow certain users on the system to place malicious code into certain key directories, or to replace programs with malicious ones. A malicious local user could use this technique to hijack the privileges of other local users, running commands with their privileges.
''',
'recommendation': '''Programs run by multiple users should only be changable only by administrative users. The directories containing these programs should only be changable only by administrators too. Revoke write privileges for non-administrative users from the above programs and directories.''',
'supporting_data': {
'writable_progs': {
'section': "description",
'preamble': "The programs below can be modified by non-administrative users:",
},
'writable_dirs': {
'section': "description",
'preamble': "The directories below can be changed by non-administrative users:",
},
}
},
'WPC002': {
'title': "Insecure Permissions on Files and Directories in Path (OBSELETE ISSUE)",
'description': '''Some of the programs and directories in the %PATH% variable could be changed by non-administrative users.
This could allow certain users on the system to place malicious code into certain key directories, or to replace programs with malicious ones. A malicious local user could use this technique to hijack the privileges of other local users, running commands with their privileges.
''',
'recommendation': '''Programs run by multiple users should only be changable only by administrative users. The directories containing these programs should only be changable only by administrators too. Revoke write privileges for non-administrative users from the above programs and directories.''',
'supporting_data': {
'writable_progs': {
'section': "description",
'preamble': "The programs below are in the path of the user used to carry out this audit. Each one can be changed by non-administrative users:",
},
'writable_dirs': {
'section': "description",
'preamble': "The directories below are in the path of the user used to carry out this audit. Each one can be changed by non-administrative users:",
}
}
},
'WPC003': {
'title': "Insecure Permissions In Windows Registry",
'description': '''Some registry keys that hold the names of programs run by other users were checked and found to have insecure permissions. It would be possible for non-administrative users to modify the registry to cause a different programs to be run. This weakness could be abused by low-privileged users to run commands of their choosing with higher privileges.''',
'recommendation': '''Modify the permissions on the above registry keys to allow only administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_reg_paths': {
'section': "description",
'preamble': "The registry keys below could be changed by non-administrative users:",
},
}
},
'WPC004': {
'title': "Insecure Permissions On Windows Service Executables",
'description': '''Some of the programs that are run when Windows Services start were found to have weak file permissions. It is possible for non-administrative local users to replace some of the Windows Service executables with malicious programs.''',
'recommendation': '''Modify the permissions on the above programs to allow only administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_progs': {
'section': "description",
'preamble': "The programs below could be changed by non-administrative users:",
},
}
},
'WPC005': {
'title': "Insecure Permissions On Windows Service Registry Keys (NOT IMPLEMENTED YET)",
'description': '''Some registry keys that hold the names of programs that are run when Windows Services start were found to have weak file permissions. They could be changed by non-administrative users to cause malicious programs to be run instead of the intended Windows Service Executable.''',
'recommendation': '''Modify the permissions on the above programs to allow only administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_reg_paths': {
'section': "description",
'preamble': "The registry keys below could be changed by non-administrative users:",
},
}
},
'WPC007': {
'title': "Insecure Permissions On Event Log File",
'description': '''Some of the Event Log files could be changed by non-administrative users. This may allow attackers to cover their tracks.''',
'recommendation': '''Modify the permissions on the above files to allow only administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_eventlog_file': {
'section': "description",
'preamble': "The files below could be changed by non-administrative users:",
},
}
},
'WPC008': {
'title': "Insecure Permissions On Event Log DLL",
'description': '''Some DLL files used by Event Viewer to display logs could be changed by non-administrative users. It may be possible to replace these with a view to having code run when an administrative user next views log files.''',
'recommendation': '''Modify the permissions on the above DLLs to allow only administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_eventlog_dll': {
'section': "description",
'preamble': "The DLL files below could be changed by non-administrative users:",
},
}
},
'WPC009': {
'title': "Insecure Permissions On Event Log Registry Key (NOT IMPLMENTED YET)",
'description': '''Some registry keys that hold the names of DLLs used by Event Viewer and the location of Log Files are writable by non-administrative users. It may be possible to maliciouly alter the registry to change the location of log files or run malicious code.''',
'recommendation': '''Modify the permissions on the above programs to allow only administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_eventlog_key': {
'section': "description",
'preamble': "The registry keys below could be changed by non-administrative users:",
},
}
},
'WPC010': {
'title': "Insecure Permissions On Drive Root",
'description': '''Some of the local drive roots allow non-administrative users to create files and folders. This could allow malicious files to be placed in on the server in the hope that they'll allow a local user to escalate privileges (e.g. create program.exe which might get accidentally launched by another user).''',
'recommendation': '''Modify the permissions on the drive roots to only allow administrators write access. Revoke write access from low-privileged users.''',
'supporting_data': {
'writable_drive_root': {
'section': "description",
'preamble': "The following drives allow non-administrative users to write to their root directory:",
},
}
},
'WPC011': {
'title': "Insecure (Non-NTFS) File System Used",
'description': '''Some local drives use Non-NTFS file systems. These drive therefore don't allow secure file permissions to be used. Any local user can change any data on these drives.''',
'recommendation': '''Use NTFS filesystems instead of FAT. Ensure that strong file permissions are set - NTFS file permissions are insecure by default after FAT file systems are converted.''',
'supporting_data': {
'fat_fs_drives': {
'section': "description",
'preamble': "The following drives use Non-NTFS file systems:",
},
}
},
'WPC012': {
'title': "Insecure Permissions On Windows Services",
'description': '''Some of the Windows Services installed have weak permissions. This could allow non-administrators to manipulate services to their own advantage. The impact depends on the permissions granted, but can include starting services, stopping service or even reconfiguring them to run a different program. This can lead to denial of service or even privilege escalation if the service is running as a user with more privilege than a malicious local user.''',
'recommendation': '''Review the permissions that have been granted to non-administrative users and revoke access where possible.''',
'supporting_data': {
'weak_service_perms': {
'section': "description",
'preamble': "Some Windows Services can be manipulated by non-administrator users:",
},
}
},
'WPC013': {
'title': "Insecure Permissions On Files / Directories In System PATH",
'description': '''Some programs/directories in the system path have weak permissions. TODO which user are affected by this issue?''',
'recommendation': '''Review the permissions that have been granted to non-administrative users and revoke access where possible.''',
'supporting_data': {
'weak_perms_exe': {
'section': "description",
'preamble': "The following programs/DLLs in the system PATH can be manipulated by non-administrator users:",
},
'weak_perms_dir': {
'section': "description",
'preamble': "The following directories in the system PATH can be manipulated by non-administrator users:",
},
}
},
'WPC014': {
'title': "Insecure Permissions On Files / Directories In Current User's PATH",
'description': '''Some programs/directories in the path of the user used to perform this audit have weak permissions. TODO which user was used to perform this audit?''',
'recommendation': '''Review the permissions that have been granted to non-administrative users and revoke access where possible.''',
'supporting_data': {
'weak_perms_exe': {
'section': "description",
'preamble': "The following programs/DLLs in current user's PATH can be manipulated by non-administrator users:",
},
'weak_perms_dir': {
'section': "description",
'preamble': "The following directories in the current user's PATH can be manipulated by non-administrator users:",
},
}
},
'WPC015': {
'title': "Insecure Permissions On Files / Directories In Users' PATHs (NEED TO CHECK THIS WORKS)",
'description': '''Some programs/directories in the paths of users on this system have weak permissions.''',
'recommendation': '''Review the permissions that have been granted to non-administrative users and revoke access where possible.''',
'supporting_data': {
'weak_perms_exe': {
'section': "description",
'preamble': "The following programs/DLLs in users' PATHs can be manipulated by non-administrator users:",
},
'weak_perms_dir': {
'section': "description",
'preamble': "The following directories in users' PATHs can be manipulated by non-administrator users:",
},
}
},
'WPC016': {
'title': "Insecure Permissions On Running Programs",
'description': '''Some programs running at the time of the audit have weak file permissions. The corresponding programs could be altered by non-administrator users.''',
'recommendation': '''Review the permissions that have been granted to non-administrative users and revoke access where possible.''',
'supporting_data': {
'weak_perms_exes': {
'section': "description",
'preamble': "The following programs were running at the time of the audit, but could be changed on-disk by non-administrator users:",
},
'weak_perms_dlls': {
'section': "description",
'preamble': "The following DLLs are used by program which were running at the time of the audit. These DLLs can be changed on-disk by non-administrator users:",
},
}
},
'WPC017': {
'title': "Shares Accessible By Non-Admin Users",
'description': '''The share-level permissions on some Windows file shares allows access by non-administrative users. This can often be desirable, in which case this issue can be ignored. However, sometimes it can allow data to be stolen or programs to be malciously modified. NB: Setting strong NTFS permissions can sometimes mean that data which seems to be exposed on a share actually isn't accessible.''',
'recommendation': '''Review the share-level permissions that have been granted to non-administrative users and revoke access where possible. Share-level permissions can be viewed in Windows Explorer: Right-click folder | Sharing and Security | "Sharing" tab | "Permissions" button (for XP - other OSs may vary slightly).''',
'supporting_data': {
'non_admin_shares': {
'section': "description",
'preamble': "The following shares are accessible by non-administrative users:",
},
}
},
}
issue_template_html = '''
<h3>REPLACE_TITLE</h3>
<table>
<tr>
<td>
<b>Description</b>
</td>
<td>
REPLACE_DESCRIPTION
REPLACE_DESCRIPTION_DATA
</td>
</tr>
<tr>
<td>
<b>Recommendation</b>
</td>
<td>
REPLACE_RECOMMENDATION
REPLACE_RECOMMENDATION_DATA
</td>
</tr>
</table>
'''
issue_list_html ='''
REPLACE_PREAMBLE
<ul>
REPLACE_ITEM
</ul>
'''
# TODO nice looking css, internal links, risk ratings
# TODO record group members for audit user, separate date and time; os and sp
overview_template_html = '''
<html>