Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

Free Oracle Tips

HTML Text

 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB   


 

 

 


 

 

 

 

 

Automated Checksum Collection for PLSQL

Oracle Forensics tips by Paul Wright

Automated checksum collection for PLSQL packages using SHA1:

SHA1DBPACKAGESTATECHECKER.sql

--this query will run from the victim server
set wrap off
set linesize 400
set serveroutput on

CREATE OR REPLACE PROCEDURE SHA1DBPACKAGESTATECHECKER(lvschema in varchar2) AS TYPE C_TYPE IS REF CURSOR;

CV C_TYPE;
   string varchar2(32767);
   l_hash raw(2000);
   lvname VARCHAR2(30);
   lvtype varchar2(30) :='PACKAGE';

begin

   OPEN CV FOR 'SELECT DISTINCT OBJECT_NAME FROM SYS.ALL_OBJECTS WHERE OBJECT_TYPE=''PACKAGE'' AND OWNER = :x' using lvschema;

   LOOP
   FETCH CV INTO lvname;
   DBMS_OUTPUT.ENABLE(200000);

   l_hash:=dbms_crypto.hash(dbms_metadata.get_ddl(lvtype, lvname, lvschema), dbms_crypto.hash_sh1);

   dbms_output.put_line('insert into SHA1PACKAGESTATES values('''||lvschema||''','''||lvname||''','''||l_hash||''');');

   EXIT WHEN CV%NOTFOUND;
 END LOOP;
 CLOSE CV;
end;
/

SQL> spool \mnt\usbdatadrive\sha1packagestate.sql
SQL> EXEC SHA1DBPACKAGESTATECHECKER('SYS');
SQL> spool off

--then afterwards reinstate the checksums in a table on the collection server.

CREATE TABLE SHA1PACKAGESTATES(SHA1SCHEMA VARCHAR2(40), SHA1NAME VARCHAR2(40), SHA1CHECKSUM VARCHAR2(40));

SQL> @sha1packagestate.sql

1 row created.

1 row created.

The query should be ran dumping the results to SQL*PLUS which can be spooled off on the victim server to the evidence data drive.

This is an implementation of SHA1 automated checksum collection for VIEWS on the collection server after the source has been copied over.

SHA1DBVIEWSTATECHECKER.sql

--this is the collection server side query
set wrap off
set linesize 400
set serveroutput on 

DROP TABLE SHA1VIEWSTATES 

CREATE TABLE SHA1VIEWSTATES(SHA1SCHEMA VARCHAR2(40), SHA1NAME VARCHAR2(40), SHA1CHECKSUM VARCHAR2(40));

CREATE OR REPLACE PROCEDURE SHA1DBVIEWSTATECHECKER(lvschema in varchar2) AS TYPE C_TYPE IS REF CURSOR;

CV C_TYPE;
   string varchar2(32767);
   l_hash raw(2000);
   lvname VARCHAR2(30);
   lvtype varchar2(30) :='VIEW';

begin

   OPEN CV FOR 'SELECT DISTINCT OBJECT_NAME FROM SYS.DBA_OBJECTS WHERE OBJECT_TYPE=''VIEW'' AND OWNER = :x' using lvschema;

   LOOP

   FETCH CV INTO lvname;

   DBMS_OUTPUT.ENABLE(200000);

   l_hash:=dbms_crypto.hash(dbms_metadata.get_ddl(lvtype, lvname, lvschema), dbms_crypto.hash_sh1);

   dbms_output.put_line('HashSHA1='||l_hash||' Name='||lvschema||'.'||lvname);

   insert into SHA1VIEWSTATES values(lvschema, lvname, l_hash);

   EXIT WHEN CV%NOTFOUND;
 END LOOP;
 CLOSE CV;
end;

EXEC SHA1DBVIEWSTATECHECKER('SYS'); 
SELECT * FROM SHA1VIEWSTATES;


Later on, when the source tables have been copied over using the SQL*PLUS COPY command, the checksums can be calculated on the collection server and compared to those on the victim server using this type of query. This will find the combination of differences. If both tables are identical there should be no resultset but need to check as always.

(((select * from SHA1PACKAGESTATEVIEWS)minus
(select * from SHA1PACKAGESTATEVIEWSNEW))UNION
((select * from SHA1PACKAGESTATEVIEWSNEW)minus
(select * from SHA1PACKAGESTATEVIEWS)))



This is an excerpt from the book "Oracle Forensics: Oracle Security Best Practices", by Paul M. Wright, the father of Oracle Forensics.

 


 

 
  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2011 by Burleson Enterprises

All rights reserved.

Oracle © is the registered trademark of Oracle Corporation.