Skip to Main Content
  • Questions
  • Plsql code Wrap for proceduer or function or package

Breadcrumb

May 4th

Question and Answer

Chris Saxon

Thanks for the question, Mohammad.

Asked: March 29, 2016 - 9:30 am UTC

Last updated: April 05, 2016 - 1:59 am UTC

Version: 11.2

Viewed 10K+ times! This question is

You Asked

Dear Tom,

I have maked plsql wrap for oracle database procedure, but there is some sites making un-wrap like " http://www.codecrete.net/UnwrapIt/", So i trying to wrap same procedure with different wrap utility "Wrap80" and it working using base64 encoded, and there is no way to un-wrap it, but the wrap does not working if the plsql code has some reserved word like "CASE" Or "LISTAGG", if i removed the reserved word its working proberly.

Please if you have information about this subject to inform me, Thank you in advance.

In addition when I make a plsql code wrap it working for wrap80 they worked based64 encoded but in case the code has some reserved word like case it does not wraping the procedure..

Best Regards

and Chris said...

Wrap80 is simply the original version of wrap. It came out with Oracle 8.0

The bottom line is that the wrap utility is not encryption, it is simply obfuscation. We know of no way to truly encrypt PL/SQL code or to stop a person from using an unwrap utility to make at least some of the code visible.

We suggest you move all your code into PL/SQL packages, rather than schema-level procedures and functions. Wrapped packages do not unwrap as easily, plus you can at least limit the exposure of the contents of package bodies to developers (but not someone with sysdba experience or who can connect to the schema owning the code).

(Thanks to Connor and Steven Feuerstein for additional comments)

Rating

  (7 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Wrap PLSQL

Mohammad Jarwan, March 31, 2016 - 11:52 am UTC

Thank you for your response, But the broblem not in wrapping for procedure or function or package,

My problem that the wrap utility does not wrap the code if the code has a "CASE" statement,

For example : when PLSQL code has "CASE" the wrap does not work, And if i replace the "CASE" by "DECODE" Then the wrap utility will wrapp the code..

Thank you in advance,
And Sorry for any inconvenience.

Wrap PLSQL

Mohammad Jarwan, March 31, 2016 - 11:57 am UTC

Thank you for your response, But the broblem not in wrapping for procedure or function or package,

My problem that the wrap utility does not wrap the code if the code has a "CASE" statement,

For example : when PLSQL code has "CASE" statment the wrap utility does not do anything, And if i replaced the "CASE" by "DECODE" Then the wrap utility will wrapp the code.

can you help me please.

Thank you in advance,
And Sorry for any inconvenience.

edebug=wrap_new_sql

Anton, March 31, 2016 - 1:01 pm UTC

The wrap version included with Oracle 9.2 has an extra parameter which can be used if new SQL features are used: edebug=wrap_new_sql See https://docs.oracle.com/cd/A97630_01/appdev.920/a96624/c_wrap.htm By the way, packages aren't harder to unwrap.
Chris Saxon
March 31, 2016 - 1:31 pm UTC

Thanks for your input Anton.

I was basing that statement on Pete Finnigans (admittedly now older) paper http://www.plsql.cz/BH-US-06-Finnigan.pdf


Wrapping PLSQL

Mohammad Jarwan, April 03, 2016 - 8:07 am UTC

Thank you for your response,

But i have a wrapped code does not able to unwrap, but this code does not have a "CASE" statement for example, so it will not able to unwrap,

But if i add a "CASE" statment to PLSQL code for example, the wrap will not working.

If you can unwrap the below code so you right, But i am sure the below code will not unwrap.

My broblem is when the code has some reserved word the wrap does not working, with knowledge that i talking about the wrap code that you can not un-wrapping it,

Find below PLSQL code :


CREATE OR REPLACE PROCEDURE DBLOGMJ wrapped
0
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
8003000
1
4
0
3
7 DBLOGMJ:
5 DBLOG:
6 OTHERS:
0

0
0
17
2
0 1d 9a b4 55 6a a0 57
b3 b7 a0 53 4f b7 a6 9
a4 b1 11 68 4f 17 b5
17
2
0 3 4 14 15 19 1d 21
26 27 29 1 2d 2f 31 32
37 3b 3d 48 4c 4e 55
17
2
0 1 b 0 :2 1 :3 2 1 :2 10
5 17 :2 b :7 1
17
2
0 :2 1 0 :2 1 :3 c b :2 d e
:4 d :6 1
57
2
:4 0 1 :a 0 13 1 :4 0 3 :2 0
13 2 4 :2 0 2 :3 0 6 8
:2 0 9 0 3 12 3 :4 0 d
5 f 7 e d :2 0 10 9
:2 0 12 0 12 11 9 10 :6 0
13 0 2 4 12 15 :2 0 1
13 16 :6 0
b
2
:3 0 1 7 1 c 1 b 1
f
1
4
0
15
0
1
14
1
1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0
2 0 1
0


Thank you in advance.
Best regards
Connor McDonald
April 03, 2016 - 11:28 am UTC

Did you try the option as proposed by Anton a few reviews earlier ?

Wrap PLSQL code

Mohammad Jarwan, April 03, 2016 - 11:45 am UTC

Yes i have seen it, but i think my broblem does not clear enough for you,

From first and detail..
I have a function and this function has a simple query
as below :

"
SELECT 1
INTO VN_TEMP
FROM DUAL
WHERE P_ID IS NOT NULL;
"

And i wrap this function in way that doesn't able to unwarp, and it wrapped successfuly..

And after that i add a "CASE" as below :

"
SELECT CASE WHEN P_ID IS NOT NULL THEN 1 ELSE 0 END
INTO VN_TEMP
FROM DUAL;
"

It's not working after i added the "CASE" condition,

Note : I have used the wrap80.exe utility.

I wish it clear..

Thank you
And Sorry for any inconvenience
Connor McDonald
April 04, 2016 - 1:17 am UTC

Sorry, I can't reproduce with 11.2.0.4

my_proc.sql
===========
create or replace
procedure my_proc(p_id int) is

VN_TEMP int;
begin

SELECT CASE WHEN P_ID IS NOT NULL THEN 1 ELSE 0 END
INTO VN_TEMP
FROM DUAL
WHERE P_ID IS NOT NULL;

end;
/

C:\temp>wrap iname=my_proc.sql oname=my_proc.wrap

PL/SQL Wrapper: Release 11.2.0.4.0- 64bit Production on Mon Apr 04 09:12:07 2016

Copyright (c) 1993, 2009, Oracle. All rights reserved.

Processing my_proc.sql to my_proc.wrap


my_proc.wrap
============
create or replace
procedure my_proc wrapped
a000000
b2
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
a3 c6
JWRAY+TMPZjfSTily5+/YxtmE9Uwg0zwmMvhf3Q2JnOUuuZbMuXvfy/6waJCZ1isq6RRhrsI
vfSsn6CCEwybdiM4ehmGOqO5BXrgZ3dhhNii3VyAhq1khbP3csz0xZn4OSRc1M0VGGTDayY1
mOeD8ihwLZUc2PuRN9IKsyYaiGuu4cKsc7VJduNHxxMoRzM+Iw==

/

which then ran into the database fine

SQL> create or replace
  2  procedure my_proc wrapped
  3  a000000
  4  b2
  5  abcd
  6  abcd
  7  abcd
  8  abcd
  9  abcd
 10  abcd
 11  abcd
 12  abcd
 13  abcd
 14  abcd
 15  abcd
 16  abcd
 17  abcd
 18  abcd
 19  abcd
 20  7
 21  a3 c6
 22  JWRAY+TMPZjfSTily5+/YxtmE9Uwg0zwmMvhf3Q2JnOUuuZbMuXvfy/6waJCZ1isq6RRhrsI
 23  vfSsn6CCEwybdiM4ehmGOqO5BXrgZ3dhhNii3VyAhq1khbP3csz0xZn4OSRc1M0VGGTDayY1
 24  mOeD8ihwLZUc2PuRN9IKsyYaiGuu4cKsc7VJduNHxxMoRzM+Iw==
 25
 26  /

Procedure created.

SQL> exec my_proc(1)

PL/SQL procedure successfully completed.



Cheers,
Connor

Wrap PLSQL code

Mohammad Jarwan, April 04, 2016 - 7:13 am UTC

Hello Sir,

Hope you are doing fine, i would like to ask if there is any update on this issue, for a refreshment and more clarification i would like to rephrase my question.

I have found a way to wrap PL-SQL code that cannot be un-wrapped in anyway, but I have an issue in this utility “Wrap80.exe”, this utility has some constraints on having some specific “reserved words, i.e. Case, Listagg … “ if any of these words exists in the code the utility does not function, but when I substitute any of these reserved words with another reserved word that is supported by the utility it works perfectly “ex. Substituting the (Case) with (Decode)”.

My question is there any oracle update, utility update or do you have any knowledge on how to overcome this problem without going through the hall code and changing the unsupported reserved words with the supported ones? As doing so would be time consuming and not that efficient.

Thank you in advance.
Connor McDonald
April 04, 2016 - 8:51 am UTC

Dont use wrap80.

Its from Oracle 8.0

Use the standard wrap facility.

Mohammad Jarwan, April 04, 2016 - 1:35 pm UTC

If i using the standard wrap facility then it will unwrapped..
I need to working on wrap80 to make the wrapped code will not unwrapped..

Did you have any update or idea ?
Chris Saxon
April 05, 2016 - 1:59 am UTC

Sorry, but using 'wrap80' is like saying "I'm deleting the code to make sure its not unwrapped".

wrap80 is from a database version that is no longer supported, so even if it gives the *appearance* of working, if one of your customers later complains that the code does not compile, or worse, does a function that its not supposed to do...what do you say ?

From Note 341504.1

"Although wrapping a compilation unit helps to hide the algorithm and makes reverse-engineering harder, Oracle Corporation does not recommend it as a secure method for hiding passwords or table names."

We dont claim wrap as a bulletproof encryption mechanism for your code, it's merely there to stop casual observation.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library