473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

any way to obsfucate a stored proc?

Hi all,
I have a software product that includes stored procedures using sql. Is
there a way to obsfucate or otherwise NOT deliver readable source to a
stored procedure? I don't really want to write the SP in java or C. SQL does
what I need just fine. I want to prevent the customer from viewing the
source of the stored procedure. Also, if I did write the stored procedure in
C is performance generally slower or faster than an equivalent SP in sql.
The SP performs several selects using dynamic sql .
Thanks in advance..
Nov 12 '05 #1
8 2008
An SQL stored procedure is still compiled (at present) via a C compiler,
and the code stored within the system. The source is stored (I believe)
in the catalog tables, so the customer would have to be rather savvy to
figure it out, but then, HEY! there are savvy customers!

You're probably better off using a C SP and not delivering the code. It
may prove to be faster, may not, since, as I said, the SQL stored
procedure is compiled into executables anyway.

When delivering the product, you could deliver the executables and update
the catalog to not have the source of the SQL SP stored. <shrug> At
least I *THINK* you might be able to do this.

Mairhtin
"John Reynolds" <no****@nowhere.com> wrote in
news:Hu*****************@fe2.columbus.rr.com:
Hi all,
I have a software product that includes stored procedures using sql.
Is there a way to obsfucate or otherwise NOT deliver readable source
to a stored procedure? I don't really want to write the SP in java or
C. SQL does what I need just fine. I want to prevent the customer from
viewing the source of the stored procedure. Also, if I did write the
stored procedure in C is performance generally slower or faster than
an equivalent SP in sql. The SP performs several selects using
dynamic sql . Thanks in advance..


Nov 12 '05 #2
Take a look at the GET_ROUTINE and PUT_ROUTINE procedures.
You can deploy a stored procedure without it's source code.
That's one of teh main reasons why GET and PUT still makes sense in DB2
V8.2.

Cheers
Serge
Nov 12 '05 #3
Hello,

mairhtin o'feannag wrote:
An SQL stored procedure is still compiled (at present) via a C compiler,


This is true for versions prior to 8.2.. There is no c-compiler needed
for writing sql stored procedures on Stinger.

Norbert
Nov 12 '05 #4
Thanks, that works great to hide my source of the SP. I can not find a
similar command or syntax that allows the same for a trigger. Can a trigger
be delivered in a similar fashion?

"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:2t*************@uni-berlin.de...
Take a look at the GET_ROUTINE and PUT_ROUTINE procedures.
You can deploy a stored procedure without it's source code.
That's one of teh main reasons why GET and PUT still makes sense in DB2
V8.2.

Cheers
Serge

Nov 12 '05 #5
Hi John,

Not as such. If you are on DB2 V8.2 you may be able to push teh logic
into a procedure and use a CALL.
This works for Triggers and SQL UDF alike.
The problem with these objects is that they are macro expanded into the
invoking statement (like a view) so DB2 needs the code.

May I ask a curious question though for my own education?
Do you just want to hide the text from _plain_ sight or do you actually
want to encrypt.
The reason why I ask is that all the information about a trigger,
function, check constraint... is also stored in teh packed descriptor of
the table/function (which is a BLOB). So simply removing it from the
TEXT column is conceptually easy. But a simple db2cat maintenace command
would unravel the mysteries ;-)

If you wanted encryption. Would YOU need to be able to descrypt (using a
password)?

Cheers
Serge
Nov 12 '05 #6
JS
Serge Rielau <sr*****@ca.ibm.com> wrote in message news:<2t*************@uni-berlin.de>...
Take a look at the GET_ROUTINE and PUT_ROUTINE procedures.
You can deploy a stored procedure without it's source code.
That's one of teh main reasons why GET and PUT still makes sense in DB2
V8.2.

Cheers
Serge


my experience on windows platform is that get and put may not work
correctly, if you get sql0444n reason code 4 when calling the SP the
fun is just beginning!
Nov 12 '05 #7
Yes , I am on 8.2 on a Windows XP platform, I tested the get/put, and had no
issues like JS describes. I have pushed most logic down into the SP. The
trigger doesn't contain anything really novel. My product is protected by a
signed software license agreement with the customer (not shrinked wrapped or
EULA), so hopefully the customer would honor that. However, I am the
paranoid type, and would like to still make it as difficult as possible for
a 'well meaning' programmer to copy/paste the code to an in-house
development effort, ... or (in this case) another vendor dealing with other
apps that access the database 'inadvertently' view the code and become aware
of the techniques used. So to answer your question, I am looking for a truly
secure delivery method that allows the SP to be executed, but cannot be (not
without great difficulty) viewed or reversed engineered, etc. Encryption is
the best answer, depending on when/who does the decryption at run time and
if other processes could spy on the process to read the unencrypted
executable byte codes. Also, SQL traces would reveal hints as to the inner
workings of the SP, so it would be nice if SQL issued by an encrypted SP
could not be traced (at least from db/2). It doesn't protect against network
sniffers, other hacks, etc. but for my purposes, if it is difficult enough
that you have to go out of your way to view the source, or your novice or
decent programmer can't figure out how to view it, ... that's good enough.
John

"Serge Rielau" <sr*****@ca.ibm.com> wrote in message
news:2t*************@uni-berlin.de...
Hi John,

Not as such. If you are on DB2 V8.2 you may be able to push teh logic into
a procedure and use a CALL.
This works for Triggers and SQL UDF alike.
The problem with these objects is that they are macro expanded into the
invoking statement (like a view) so DB2 needs the code.

May I ask a curious question though for my own education?
Do you just want to hide the text from _plain_ sight or do you actually
want to encrypt.
The reason why I ask is that all the information about a trigger,
function, check constraint... is also stored in teh packed descriptor of
the table/function (which is a BLOB). So simply removing it from the TEXT
column is conceptually easy. But a simple db2cat maintenace command would
unravel the mysteries ;-)

If you wanted encryption. Would YOU need to be able to descrypt (using a
password)?

Cheers
Serge

Nov 12 '05 #8
You kind of confirm my thinking that there are three levels of paranoia:
1. Thou shall not invite theft of IP
(I.e. if you're not malicious you will not get tempted)
2. Encryption of the static code
3. Encryption of tracing.

Points two and three are more tricky.
Thing is if something goes wrong:
* you want to get access
* DB2 supports wants to get access
This really means two copies.
One encrypted with your password, one with IBMs
Also in case of a trigger, function or even a view teh DB2 engine must
be able to unravel the mystery.

The third problem is the toughest.
If you want to drive the point home then even an optimizer plan is
living in teh danger zone, along with the SQL Procedure Tracer I
introduced in V8.2. Even db2trc is dangerous.

Cheers
Serge
Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: June Moore | last post by:
Hi all, I have a stored procedure that return a resultset e.g. stored proc: get_employee_details select emp_id, emp_name, emp_salary, emp_position from empoloyee I would like to write...
9
by: Wolfgang Kreuzer | last post by:
Try hard to become familiar with T-SQL. Can anybodey tell me the best way to deal with set's provided by a stored procedure. Til yesterday I thougt trapping set in temp table using INSERT EXEC...
4
by: Nyul | last post by:
Gurus, I have a verb big problem which I'm unable to explain. We have a DB2 V6.1.0 on AIX 4.3 I want to make a C stored procedure which at the end will be called by a PHP script. The...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
5
by: Rhino | last post by:
This question relates to DB2 Version 6 on OS/390. Can a (COBOL) stored procedure on this platform do file I/O, i.e. write to a sequential file? I am trying to debug a stored procedure. As far...
2
by: Rhino | last post by:
I am getting an sqlcode of -927 when I execute SQL within a COBOL stored procedure in DB2 OS/390 Version 6 on OS/390. I have looked at the error message for that condition and tried everything I...
1
by: mike | last post by:
If I try and do a "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1" after I have run a stored procedure in DB2 version 7.2, I get the last generated Key before the CallableStatement was executed...
14
by: Roy | last post by:
Apologies for the cross-post, but this truly is a two-sided question. Given the option of creating Looping statements within a stored proc of sql server or in the code-behind of an .net webpage,...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.