-
Notifications
You must be signed in to change notification settings - Fork 7
/
Oracle11g-Checks.sql
1822 lines (1600 loc) · 32.3 KB
/
Oracle11g-Checks.sql
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
/*
Run this script sqlplus system/password@ServerName:Port/ServiceName @Oracle11g-Checks.sql
Output filename is : DBName_yymmdd_Security_Checks.html
*/
Prompt
Prompt ***** THE START OF SECURITY CHECKS REPORT ******
Prompt ***** IT CAN TAKE TIME PLEASE WAIT..... ******
Prompt
set pagesize 10000
SET TERMOUT OFF
SET RECSEP WRAPPED
colum expiry_date format a15
column GRANTED_CRITIC_ROLE format A20
column ADMIN_OPTION format A15
column COMMON format A15
column SYSDBA format A15
column SYSOPER format A15
column SYSASM format A15
column SYSBACKUP format A15
column SYSDG format A15
column SYSKM format A15
column DB_UNIQUE_NAME format A15
column AUDIT_TRAIL format A15
column POLICY_COLUMN_OPTIONS format A25
column ENABLED format A15
column OBJECT_SCHEMA format A15
column OBJECT_NAME format A32
column POLICY_OWNER format A15
column POLICY_NAME format A25
column POLICY_TEXT format A32
column POLICY_COLUMN format A15
column PF_SCHEMA format A15
column PF_PACKAGE format A15
column PF_FUNCTION format A15
column PRIVILEGE format A15
column IS_GRANT format A15
column INVERT format A15
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD '<TITLE> </TITLE> -
<STYLE type="text/css"> -
th { -
font:bold 10pt Ariel,Helvetica,sans-serif; -
color:#336699; -
background:#cccc99; -
padding:3px 3px 3px 3px;} -
td { -
font: 9pt Arial,Helvetica,sans-serif; -
color:black; -
background:white; -
padding:2px 2px 2px 2px;} -
</STYLE>' -
BODY 'TEXT="#00000"' -
TABLE 'WIDTH="60%" BORDER="1"'
column filename new_val filename
select name||'_'||to_char(sysdate, 'yyyymmdd' )||'_Security_Checks.html' filename from dual , v$database;
spool &filename
set define off
SET MARKUP HTML OFF
Prompt <h2> Oracle 11g Security Check SQLs </h2>
Prompt <p>Open Source code from https://github.com/yusufanilakduygu/Oracle-DB-Security-Checks </p>
Prompt <p>This Report was developed by Y. Anil Akduygu ver 1.2 2018 </p>
Prompt <h3> Server and Database Information </h3>
SET MARKUP HTML ON
SELECT to_char(SYSDATE,'dd-mm-yyyy hh24:mi') REPORT_DATE,
SUBSTR (host_name, 1, 20) HOST_NAME,
name,
database_role,
SUBSTR (open_mode, 1, 10) OPEN_MODE,
SUBSTR (db_unique_name, 1, 10) DB_UNIQUE_NAME
FROM v$database, v$instance;
SET MARKUP HTML OFF
prompt </b>
prompt <h3> Database version </h3>
SET MARKUP HTML ON
SELECT BANNER "DB VERSION INFORMATION" from v$version;
SET MARKUP HTML OFF
prompt </b>
prompt <h3> Check - 010 User List </h3>
SET MARKUP HTML ON
colum expiry_date format a15
SELECT
USERNAME,
ACCOUNT_STATUS,
TO_CHAR(EXPIRY_DATE,'DD-MM-YYYY') EXPIRY_DATE,
TO_CHAR(CREATED,'DD-MM-YYYY')CREATED
FROM
DBA_USERS
ORDER BY
ACCOUNT_STATUS DESC , USERNAME ASC;
SET MARKUP HTML OFF
prompt <h3> Check - 020 List Permanent and Temporary Tablespaces </h3>
SET MARKUP HTML ON
SELECT
PROPERTY_NAME,
PROPERTY_VALUE
FROM
DATABASE_PROPERTIES
WHERE
PROPERTY_NAME IN(
'DEFAULT_PERMANENT_TABLESPACE',
'DEFAULT_TEMP_TABLESPACE'
);
SET MARKUP HTML OFF
prompt <h3> Check - 030 Users which use SYSTEM and SYSAUX as Default Tablespaces </h3>
SET MARKUP HTML ON
SELECT
USERNAME,
DEFAULT_TABLESPACE,
TEMPORARY_TABLESPACE
FROM
DBA_USERS
WHERE
(
DEFAULT_TABLESPACE IN(
'SYSTEM',
'SYSAUX'
)
OR TEMPORARY_TABLESPACE IN(
'SYSTEM',
'SYSAUX'
)
)
AND USERNAME NOT IN(
'ANONYMOUS',
'CTXSYS',
'DBSNMP',
'EXFSYS',
'LBACSYS',
'MDSYS',
'MGMT_VIEW',
'OLAPSYS',
'OWBSYS',
'ORDPLUGINS',
'ORDSYS',
'OUTLN',
'SI_INFORMTN_SCHEMA',
'SYS',
'SYSMAN',
'SYSTEM',
'TSMSYS',
'WK_TEST',
'WKSYS',
'WKPROXY',
'WMSYS',
'XDB',
'APEX_PUBLIC_USER',
'DIP',
'FLOWS_30000',
'FLOWS_FILES',
'MDDATA',
'ORACLE_OCM',
'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR',
'XS$NULL',
'OWBSYS_AUDIT',
'ORDDATA',
'APEX_030200',
'APPQOSSYS',
'DVSYS',
'DVF'
)
ORDER BY
ACCOUNT_STATUS DESC;
SET MARKUP HTML OFF
prompt <h3> Check - 040 List Sample Application Users </h3>
SET MARKUP HTML ON
SELECT
DISTINCT(USERNAME)
FROM
DBA_USERS
WHERE
USERNAME IN(
'BI',
'HR',
'OE',
'PM',
'IX',
'SH',
'SCOTT'
);
SET MARKUP HTML OFF
prompt <h3> Check - 050 List Database Profile Names </h3>
SET MARKUP HTML ON
SELECT
DISTINCT PROFILE
FROM
DBA_PROFILES
ORDER BY
PROFILE;
SET MARKUP HTML OFF
prompt <h3> Check - 060 List Database Profiles Details </h3>
SET MARKUP HTML ON
SELECT
*
FROM
DBA_PROFILES
ORDER BY
PROFILE;
SET MARKUP HTML OFF
prompt <h3> Check - 070 List Unused Database Profiles </h3>
SET MARKUP HTML ON
SELECT
DISTINCT PROFILE
FROM
DBA_PROFILES MINUS SELECT
DISTINCT PROFILE
FROM
DBA_USERS;
SET MARKUP HTML OFF
prompt <h3> Check - 080 List User and Profile Usage </h3>
SET MARKUP HTML ON
SELECT
USERNAME,
PROFILE
FROM
DBA_USERS
ORDER BY
PROFILE;
SET MARKUP HTML OFF
prompt <h3> Check - 080 List resource_limit parameter </h3>
SET MARKUP HTML ON
SELECT
NAME,
VALUE
FROM
V$PARAMETER
WHERE
NAME = 'resource_limit';
SET MARKUP HTML OFF
prompt <h3> Check - 090 List Resource Usage Profile Parameters </h3>
SET MARKUP HTML ON
SELECT
PROFILE,
RESOURCE_NAME,
LIMIT
FROM
DBA_PROFILES
WHERE
RESOURCE_NAME IN(
'SESSIONS_PER_USER',
'CPU_PER_SESSION',
'CPU_PER_CALL',
'CONNECT_TIME',
'IDLE_TIME',
'LOGICAL_READS_PER_SESSION',
'PRIVATE_SGA',
'COMPOSITE_LIMIT'
)
ORDER BY
PROFILE,
RESOURCE_NAME;
SET MARKUP HTML OFF
prompt <h3> Check - 100 List resource_manager_plan parameters </h3>
SET MARKUP HTML ON
SELECT
NAME,
VALUE
FROM
V$PARAMETER
WHERE
NAME LIKE 'resource_manager_plan';
SET MARKUP HTML OFF
prompt <h3> Check - 110 List Resource Plans </h3>
SET MARKUP HTML ON
SELECT
NAME,
IS_TOP_PLAN
FROM
V$RSRC_PLAN;
SET MARKUP HTML OFF
prompt <h3> Check - 120 List Password Parameters </h3>
SET MARKUP HTML ON
SELECT
PROFILE,
RESOURCE_NAME,
LIMIT
FROM
DBA_PROFILES
WHERE
RESOURCE_NAME IN(
'FAILED_LOGIN_ATTEMPTS',
'PASSWORD_LIFE_TIME',
'PASSWORD_LOCK_TIME',
'PASSWORD_GRACE_TIME',
'PASSWORD_VERIFY_FUNCTION',
'PASSWORD_REUSE_TIME',
'PASSWORD_REUSE_MAX'
)
ORDER BY
PROFILE,
RESOURCE_NAME;
SET MARKUP HTML OFF
prompt <h3> Check - 130 List Profiles with NULL Password Verify Function </h3>
SET MARKUP HTML ON
SELECT
*
FROM
DBA_PROFILES
WHERE
RESOURCE_NAME = 'PASSWORD_VERIFY_FUNCTION'
AND(
LIMIT = 'DEFAULT'
OR LIMIT IS NULL
OR LIMIT = 'NULL'
);
SET MARKUP HTML OFF
prompt <h3> Check - 140 List Default User with Default Passwords </h3>
SET MARKUP HTML ON
SELECT * FROM DBA_USERS_WITH_DEFPWD;
SET MARKUP HTML OFF
prompt <h3> Check - 150 List Default Users with default passwords and not in EXPIRED and LOCKED status </h3>
SET MARKUP HTML ON
SELECT
A.USERNAME ,
B.ACCOUNT_STATUS
FROM
SYS.DBA_USERS_WITH_DEFPWD A,
DBA_USERS B
WHERE
A.USERNAME = B.USERNAME
AND B.ACCOUNT_STATUS <> 'EXPIRED & LOCKED';
SET MARKUP HTML OFF
prompt <h3> Check - 160 List Users with DBA role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
A.GRANTED_ROLE,
'DBA' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS START WITH GRANTED_ROLE = 'DBA'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 180 List Users with IMP_FULL_DATABASE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
A.GRANTED_ROLE,
'IMP_FULL_DATABASE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'IMP_FULL_DATABASE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 190 List Users with DATAPUMP_IMP_FULL_DATABASE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
A.GRANTED_ROLE,
'DATAPUMP_IMP_FULL_DATABASE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'DATAPUMP_IMP_FULL_DATABASE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 200 List Users with EXP_FULL_DATABASE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
A.GRANTED_ROLE,
'EXP_FULL_DATABASE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'EXP_FULL_DATABASE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 210 List Users with DATAPUMP_EXP_FULL_DATABASE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
A.GRANTED_ROLE,
'DATAPUMP_EXP_FULL_DATABASE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'DATAPUMP_EXP_FULL_DATABASE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 220 List Users with SELECT_CATALOG_ROLE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
GRANTED_ROLE,
'SELECT_CATALOG_ROLE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'SELECT_CATALOG_ROLE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS',
'SYSMAN'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 230 List Users with DELETE_CATALOG_ROLE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
GRANTED_ROLE,
'DELETE_CATALOG_ROLE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'DELETE_CATALOG_ROLE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS',
'SYSMAN'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 240 List Users with EXECUTE_CATALOG_ROLE role </h3>
SET MARKUP HTML ON
SELECT
DISTINCT A.GRANTEE,
GRANTED_ROLE,
'EXECUTE_CATALOG_ROLE' GRANTED_CRITIC_ROLE
FROM
(
SELECT
DISTINCT LEVEL LEVEL_DEEP,
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
START WITH GRANTED_ROLE = 'EXECUTE_CATALOG_ROLE'
CONNECT BY PRIOR GRANTEE = GRANTED_ROLE
) A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND B.USERNAME NOT IN(
'SYSTEM',
'SYS',
'SYSMAN'
)
AND B.ACCOUNT_STATUS = 'OPEN';
SET MARKUP HTML OFF
prompt <h3> Check - 250 List remote_login_passwordfile parameter </h3>
SET MARKUP HTML ON
SELECT
NAME,
VALUE
FROM
V$PARAMETER
WHERE
NAME = 'remote_login_passwordfile';
SET MARKUP HTML OFF
prompt <h3> Check - 260 List Users which use password file </h3>
SET MARKUP HTML ON
SELECT * FROM V$PWFILE_USERS;
SET MARKUP HTML OFF
prompt <h3> Check - 270 List users and roles with critic privileges </h3>
SET MARKUP HTML ON
SELECT
A.*,
'GRANTED TO USER' TYPE
FROM
DBA_SYS_PRIVS A,
DBA_USERS B
WHERE
A.GRANTEE = B.USERNAME
AND PRIVILEGE IN(
'BECOME USER',
'ALTER USER',
'DROP USER',
'CREATE ROLE',
'ALTER ANY ROLE',
'DROP ANY ROLE',
'GRANT ANY ROLE',
'CREATE PROFILE',
'ALTER PROFILE',
'DROP PROFILE',
'CREATE ANY TABLE',
'ALTER ANY TABLE',
'DROP ANY TABLE',
'INSERT ANY TABLE',
'UPDATE ANY TABLE',
'DELETE ANY TABLE',
'SELECT ANY TABLE',
'CREATE ANY PROCEDURE',
'ALTER ANY PROCEDURE',
'DROP ANY PROCEDURE',
'EXECUTE ANY PROCEDURE',
'CREATE ANY TRIGGER',
'ALTER ANY TRIGGER',
'DROP ANY TRIGGER',
'CREATE TABLESPACE',
'ALTER TABLESPACE',
'DROP TABLESPACES',
'ALTER DATABASE',
'ALTER SYSTEM',
'SELECT ANY DICTIONARY',
'EXEMPT ACCESS POLICY',
'CREATE ANY LIBRARY',
'GRANT ANY OBJECT PRIVILEGE',
'GRANT ANY PRIVILEGE',
'AUDIT ANY'
)
AND GRANTEE NOT IN(
'ANONYMOUS',
'CTXSYS',
'DBSNMP',
'EXFSYS',
'LBACSYS',
'MDSYS',
'MGMT_VIEW',
'OLAPSYS',
'OWBSYS',
'ORDPLUGINS',
'ORDSYS',
'OUTLN',
'SI_INFORMTN_SCHEMA',
'SYS',
'SYSMAN',
'SYSTEM',
'TSMSYS',
'WK_TEST',
'WKSYS',
'WKPROXY',
'WMSYS',
'XDB',
'APEX_PUBLIC_USER',
'DIP',
'FLOWS_30000',
'FLOWS_FILES',
'MDDATA',
'ORACLE_OCM',
'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR',
'XS$NULL',
'OWBSYS_AUDIT',
'ORDDATA',
'APEX_030200',
'APPQOSSYS',
'DVSYS',
'DVF'
)
UNION ALL
SELECT
A.*,
'GRANTED TO ROLE' TYPE
FROM
DBA_SYS_PRIVS A,
DBA_ROLES B
WHERE
A.GRANTEE = B.ROLE
AND PRIVILEGE IN(
'BECOME USER',
'ALTER USER',
'DROP USER',
'CREATE ROLE',
'ALTER ANY ROLE',
'DROP ANY ROLE',
'GRANT ANY ROLE',
'CREATE PROFILE',
'ALTER PROFILE',
'DROP PROFILE',
'CREATE ANY TABLE',
'ALTER ANY TABLE',
'DROP ANY TABLE',
'INSERT ANY TABLE',
'UPDATE ANY TABLE',
'DELETE ANY TABLE',
'SELECT ANY TABLE',
'CREATE ANY PROCEDURE',
'ALTER ANY PROCEDURE',
'DROP ANY PROCEDURE',
'EXECUTE ANY PROCEDURE',
'CREATE ANY TRIGGER',
'ALTER ANY TRIGGER',
'DROP ANY TRIGGER',
'CREATE TABLESPACE',
'ALTER TABLESPACE',
'DROP TABLESPACES',
'ALTER DATABASE',
'ALTER SYSTEM',
'SELECT ANY DICTIONARY',
'EXEMPT ACCESS POLICY',
'CREATE ANY LIBRARY',
'GRANT ANY OBJECT PRIVILEGE',
'GRANT ANY PRIVILEGE',
'AUDIT ANY'
)
AND GRANTEE NOT IN(
'DBA',
'IMP_FULL_DATABASE',
'DATAPUMP_IMP_FULL_DATABASE',
'OLAP_DBA',
'EXP_FULL_DATABASE',
'OEM_MONITOR'
);
SET MARKUP HTML OFF
prompt <h3> Check - 280 List DEFAULT Packages which are granted to PUBLIC with EXECUTE privileges </h3>
SET MARKUP HTML ON
SELECT
OWNER,
TABLE_NAME,
PRIVILEGE,
GRANTEE
FROM
DBA_TAB_PRIVS
WHERE
GRANTEE = 'PUBLIC'
AND PRIVILEGE = 'EXECUTE'
AND TABLE_NAME IN(
'DBMS_ADVISOR',
'DBMS_CRYPTO',
'DBMS_JAVA',
'DBMS_JAVA_TEST',
'DBMS_JOB',
'DBMS_LDAP',
'DBMS_LOB',
'DBMS_OBFUSCATION_TOOLKIT',
'DBMS_RANDOM',
'DBMS_SCHEDULER',
'DBMS_SQL',
'DBMS_XMLGEN',
'DBMS_XMLQUERY',
'UTL_FILE',
'UTL_INADDR',
'UTL_TCP',
'UTL_MAIL',
'UTL_SMTP',
'UTL_DBWS',
'UTL_ORAMTS',
'UTL_HTTP',
'HTTPURITYPE',
'DBMS_SYS_SQL',
'DBMS_BACKUP_RESTORE',
'DBMS_AQADM_SYSCALLS',
'DBMS_REPCAT_SQL_UTL',
'INITJVMAUX',
'DBMS_STREAMS_ADM_UTL',
'DBMS_AQADM_SYS',
'DBMS_STREAMS_RPC',
'DBMS_PRVTAQIM',
'LTADM',
'WWV_DBMS_SQL',
'WWV_EXECUTE_IMMEDIATE',
'DBMS_IJOB',
'DBMS_FILE_TRANSFER'
)
ORDER BY
TABLE_NAME;
SET MARKUP HTML OFF
prompt <h3> Check - 290 List Grants on critic tables </h3>
SET MARKUP HTML ON
SELECT
GRANTEE,
PRIVILEGE,
TABLE_NAME
FROM
DBA_TAB_PRIVS
WHERE
TABLE_NAME IN(
'AUD$',
'USER_HISTORY$',
'LINK$',
'USER$',
'SCHEDULER$_CREDENTIAL'
)
AND GRANTEE NOT IN(
'ANONYMOUS',
'CTXSYS',
'DBSNMP',
'EXFSYS',
'LBACSYS',
'MDSYS',
'MGMT_VIEW',
'OLAPSYS',
'OWBSYS',
'ORDPLUGINS',
'ORDSYS',
'OUTLN',
'SI_INFORMTN_SCHEMA',
'SYS',
'SYSMAN',
'SYSTEM',
'TSMSYS',
'WK_TEST',
'WKSYS',
'WKPROXY',
'WMSYS',
'XDB',
'APEX_PUBLIC_USER',
'DIP',
'FLOWS_30000',
'FLOWS_FILES',
'MDDATA',
'ORACLE_OCM',
'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR',
'XS$NULL',
'OWBSYS_AUDIT',
'ORDDATA',
'APEX_030200',
'APPQOSSYS',
'DVSYS',
'DVF'
);
SET MARKUP HTML OFF
prompt <h3> Check - 300 List Objects Priviliges Granted to Public </h3>
SET MARKUP HTML ON
SELECT
GRANTEE,
OWNER,
TABLE_NAME,
PRIVILEGE
FROM
DBA_TAB_PRIVS
WHERE
GRANTEE = 'PUBLIC'
AND OWNER NOT IN(
'ANONYMOUS',
'CTXSYS',
'DBSNMP',
'EXFSYS',
'LBACSYS',
'MDSYS',
'MGMT_VIEW',
'OLAPSYS',
'OWBSYS',
'ORDPLUGINS',
'ORDSYS',
'OUTLN',
'SI_INFORMTN_SCHEMA',
'SYS',
'SYSMAN',
'SYSTEM',
'TSMSYS',
'WK_TEST',
'WKSYS',
'WKPROXY',
'WMSYS',
'XDB',
'APEX_PUBLIC_USER',
'DIP',
'FLOWS_30000',
'FLOWS_FILES',
'MDDATA',
'ORACLE_OCM',
'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR',
'XS$NULL',
'OWBSYS_AUDIT',
'ORDDATA',
'APEX_030200',
'APPQOSSYS',
'DVSYS',
'DVF'
);
SET MARKUP HTML OFF
prompt <h3> Check - 302 List Roles Granted to Public </h3>
SET MARKUP HTML ON
SELECT
GRANTEE,
GRANTED_ROLE
FROM
DBA_ROLE_PRIVS
WHERE
GRANTEE = 'PUBLIC';
SET MARKUP HTML OFF
prompt <h3> Check - 304 List System Privileges Granted to Public </h3>
SET MARKUP HTML ON
SELECT
GRANTEE,
PRIVILEGE
FROM
DBA_SYS_PRIVS
WHERE
GRANTEE = 'PUBLIC';
SET MARKUP HTML OFF
prompt <h3> Check - 310 List Granted System Priviliges to Users with Admin Option </h3>
SET MARKUP HTML ON
SELECT
A.GRANTEE,
A.PRIVILEGE,
A.ADMIN_OPTION
FROM
DBA_SYS_PRIVS A,
DBA_USERS B
WHERE
A.ADMIN_OPTION = 'YES'
AND A.GRANTEE NOT IN(
'ANONYMOUS',
'CTXSYS',
'DBSNMP',
'EXFSYS',
'LBACSYS',
'MDSYS',
'MGMT_VIEW',
'OLAPSYS',
'OWBSYS',
'ORDPLUGINS',
'ORDSYS',
'OUTLN',
'SI_INFORMTN_SCHEMA',
'SYS',