Pete Finnigan's Oracle Security Forum (http://www.petefinnigan.com/forum/yabb/YaBB.cgi)
Oracle Security >> Oracle Security >> Unwrapping PL/SQL
(Message started by: Pete Finnigan on Aug 8th, 2006, 2:05pm)

Title: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 8th, 2006, 2:05pm
I have just posted a link to my presentation slides from Blackhat Las Vegas 2006 on my [url http://www.petefinnigan.com/orasec.htm]Oracle security white papers[/url] page. The slides can be found [url http://www.insight.co.uk/files/presentations/BlackHat%20conference.pdf]here[/url]

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 9th, 2006, 5:22pm
Pete,

It's a very interesting document. And very useful too. I think there are many wrapped pl/sql procedures for which people don't have the source anymore. I have a few wrapped pl/sql procedures written many years ago by DBA's. We know what the functionality is of these procedures but we don't have the source anymore! If we want to change them we have to reverse engineer them. I'll try to unwrap these procedures with you unwrap script.

regards,

Ivan

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 16th, 2006, 5:07pm
Pete,
Can one  unwrap a PL/SQL Package in oracle 10g?




Olivet

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 17th, 2006, 9:19am
Hi,

the example procedure included with the paper is for 9i and lower and is only a proof of concept. The 10g algorithm is completely different.

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 17th, 2006, 10:47am
Pete,
I really understand the write up and i know you delibrated much more on the process for Oracle 9i and bellow  with respect to DIANA and m code. But I have an issue in house. I have a package that we wrapped  in Oracle 10g. What the package does is to send notification to our numerious customers once a trasaction takes place in their account. We need to expand the scope of this package and we are stucked. The source code cannotbe trace again. Wehave the .plb  only. We dont want to re invent the wheel as it took some time to get to that position . I really need your advice in this case. what can we do. Can we get the souce code back from .plb or from another means.
Thak you.  


Warmest regards,
Olivet

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 18th, 2006, 1:21am
Pete,

I've read your presentation and it's very good. My question is very much from the other side. We have source which we have wrapped in order to protect our IP. Obviously this is not as protected as we had first thought. >:(

Is there anything else we should be looking at to minimise the risk of people unwrapping our code and stealing the IP given that the nature of our product means we cannot lock down the database structures (we are using 10g)?

Regards,
Graeme

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 18th, 2006, 10:22am
Hi Graeme,

The issue is really that the 10g mechanism has also been cracked. There are a number of 10g unwrappers out there. I know of at least 5 different ones. At this point in time they are not in general circulation so its unlikely that someone without connections is going to get one.

The issue is that the wrapped source is stored in SYS.SOURCE$ so even if the files are not shipped to the server somone may be able to get the wrapped source from the database and unwrap it.

Unless you can protect the wrapped source from view the intellectual property is vulnerable. In this sense the wrap mechanism does little to help protect source code.

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 21st, 2006, 6:41am
Maybe it's not something that you've looked into, but how does native compilation compare to wrapping for 'code hiding' purposes ?
Obviously that isn't its primary purpose, but maybe there's another 'layer' that can be applied on top of native compilation to obfuscate the object ?

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 21st, 2006, 5:42pm
Hi Gary,

I have looked into Native compilation in detail. I even mentioned it in the slides. The problem would be that the native PL/SQL is simply the mcode for the PL/SQL VM. The Source code and diana levels still exist, i.e the IDL$ tables still have contents and the SYS.SOURCE$ table still contains the wrapped PL/SQL so we would not gain anything from this strategy.

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 23rd, 2006, 12:00am
Hi Pete & Gary,

So to me it looks like there is no way to 100% lock down PL/SQL in order to protect IP. The 2 ways mentioned (wrapping and Native compilation)seem to only be a deterrent to prying eyes and could be read by suitably connected malicious hackers.

Not that I think the IP we are protecting will attract these hackers, our IP is still worth a considerable amount and differentiates us from the competition. From my simplistic outlook this is a big issue for IP protection within PL/SQL and a gap in the market for a good solution which can guarantee IP protection within PL/SQL.

Cheers,

Graeme

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 24th, 2006, 10:24pm
Hi Graeme,

I agree, its virtually impossible to protect your IP if a DBA has access to the SYS.SOURCE$ table. I also agree that this seems like a gap in the market to provide a tool but even if you tac something on top of PL/SQL i.e. encrypt the source and dynamically extract and run it the problem is you could still get at the source.

An obvious solutiojn is to move your code to C, OCI or Pro*C.

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Sep 12th, 2006, 8:32am
Hi!
Will you be so kind, to help me with my trouble?
I will try to explain.
We do use Spatial optins with oracle, and after applying the patchset to 9.2.0.8.0 we can't create or rebuild spatial indexes.
We taking a error like this:

11:28:48 test 8 RELEASE2>alter index test_g_idx rebuild;
alter index test_g_idx rebuild
*
ERROR at line 1:
ORA-29858: error occurred in the execution of ODCIINDEXALTER routine
ORA-29400: data cartridge error
Xjэ
ORA-13249: internal error in Spatial index: [mdidxrbd]
ORA-13205: internal error  while parsing spatial parameters
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_9I", line 259
ORA-06512: at line 1


Metalink told us, that this is a bug, and it fixed in 10R2 ;(

But at 9.2.0.7.0 we was able to create spatial indexes.
Can you help me to unwrap this package, I wish to look it, and possible to know, why it isn't working.
Thank you!

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Sep 14th, 2006, 5:34am
hi pete,
amazing, before this doc really I thought Oracle is unbreakable, about the tool you mentioned that this tool works for 10g, am i right or I missed something please clarify
regards

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Sep 14th, 2006, 10:49am
Read some more papers from Pete's website and you too will know: Oracle really isn't unbreakable.

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Mar 7th, 2007, 3:43pm
Pete,

it really works when unwrapping a PL/SQL "procedure" in 9i,
but how to unwrap a PL/SQL "Package" in 9i ?

"Write PL/SQL as packages; DIANA is not stored in the database" what does it mean in  slides ?
Am I missed anything ?


Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Mar 8th, 2007, 9:00am
Hi,

The presentation code is a proof of concept only designed to unwrap a very simple procedure whose DIANA is stored in the IDL$ tables. There is limited access to DIANA in the IDL$ tables and as stated in the paper the DIANA for packages is not stored. To unwrap packages you would need to write a complete unwrapper.

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 29th, 2007, 12:01pm
Pete,

I have a problem, when i execute EXEC SYS.DUMPDIANA.DUMP(aname => 'UL_BOOKING_REPORT') i get the following error.
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.DUMPDIANA", line 67
ORA-06512: at "SYS.DUMPDIANA", line 84
ORA-06512: at line 1

These also dont give proper result. They give the following

-
$$$ s_subpNotFound


EXEC SYS.PSTUB('UL_BOOKING_REPORT',NULL,:A,:B);
EXEC SYS.SUBPTXT('UL_BOOKING_REPORT',NULL,NULL,:A);


I did dump the datafile with proper no from UB2$ (Got it from running rowid.sql).

Pls help this procedure was created in oracle 8i.

Best Regards

Anenthan

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 29th, 2007, 2:48pm
is it a procedure or package or package body? - if its a package body then there is no DIANA stored.

I suspect your issue is that you are running the dumpdiana.dump not as the owner of the pl/sql yoy are trying to dump. if you are then add the usr=>'username' to the get_diana call in dump - you cannot pass this in as it defaults to usr=>user. this applies if you call the dump procedure. The other simpler approach is to call sys.dumpdian.get_diana directly and pass in the user name.

hth

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Oct 15th, 2007, 11:36am
hi pete,
i have this result with use unwrap_r:

Start up
CREATE OR REPLACE
**** ERROR ****
**** ERROR ****
IS BEGIN
**** ERROR ****
**** ERROR ****
**** ERROR ****
**** ERROR ****
END;
/

env. oracle 9.2.0.5

Any suggestion ?

Thanks

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Oct 15th, 2007, 3:19pm
Hi,

What are you trying to unwrap with this sample code? - the code is from my Blackhat presentation and is a proof of concept only to show how unwrapping works in 9i and lower. It was written to unwrap a simple procedure like http://www.petefinnigan.com/aa.sql only.

cheers

Pete

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Dec 4th, 2009, 8:24am
http://oracleerrormsging.blogspot.com/2009/12/internal-error-while-parsing-spatial.html

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on May 20th, 2010, 11:14am
I really understand the write up and i know you delibrated much more on the process for Oracle 9i and bellow  with respect to DIANA and m code. But I have an issue in house. I have a package that we wrapped  in Oracle 10g. What the package does is to send notification to our numerious customers once a trasaction takes place in their account. We need to expand the scope of this package and we are stucked. The source code cannotbe trace again. Wehave the .plb  only. We dont want to re invent the wheel as it took some time to get to that position . I really need your advice in this case. what can we do.

Title: Re: Unwrapping PL/SQL
Post by Pete Finnigan on Aug 10th, 2010, 9:39am
If you want to learn unwrapping PL/SQL, check Pete's library of white papers. Like this document: https://www.blackhat.com/presentations/bh-usa-06/BH-US-06-Finnigan.pdf



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board