9/14/2019 Rewrap.exe Oracle
Often developers want to wrap their code to prevent the misuse of their code and also sometimes they don’t want to expose their algorithm to the world. For such cases Oracle has come up with a utility called ‘wrap utility’ (wrap.exe) which provides a way for PL/SQL developers to protect their intellectual property by making their PL/SQL code unreadable. These encryption options have long been available for other programming languages and were introduced for PL/SQL in version 7. The wrap utility takes a readable, ASCII text file as input and converts it to a file containing byte code. The result is that the DBA, developers or anyone with database access cannot view the source code in any readable format. To run the Wrap Utility, enter the wrap command at your operating system prompt using the following syntax: wrap iname=inputfile oname=outputfile Where. iname – The name of the unencrypted PL/SQL file to be used as input (your source file).
oname – The name of the output file. This file will be encrypted. Note:. Leave no space around the equal signs because spaces delimit individual arguments. The wrap command requires only one argument, which is iname=inputfile where inputfile is the name of the Wrap Utility input file. You need not specify the file extension because it defaults to sql.
C: ProgramData Oracle Java javapath; On the 2008 server, that folder contains an actual copy of the latest version of javaws.exe; on the other servers/stations, that folder contains a.symlink shortcut to javaws.exe in its home in the program folder (not SysWOW64). From what I understand from metamath.exe documentation (below a snippet), the /rewrap modifier should 'Reformat statements and comments according to the convention used in the set.mm database.' It works perfectly for comments, but most of the statements above 80 characters are not rewrapped (but some are, I've not been able to find a pattern).
However, you can specify a different file extension such as ‘wrap iname=/mydir/myfile.src’. Optionally, the wrap command takes a second argument, which is oname=outputfile where outputfile is the name of the Wrap Utility output file. You need not specify the output file because its name defaults to that of the input file and its extension defaults to plb (PL/SQL binary). Generally, the output file is much larger than the input file. The input file can contain any combination of SQL statements. However, the Wrap Utility encrypts only the CREATE statements, which define subprograms, packages, or object types.
If your input file contains syntax errors, the Wrap Utility detects and reports them. However, the Wrap Utility cannot detect semantic errors because it does not resolve external references. To test the Wrap Utility, let’s first create a procedure (testwrapproc.sql) CREATE OR REPLACE PROCEDURE testwrapproc AS CURSOR clanguages IS SELECT ISOLANGUAGE,NLSTERRITORY FROM FNDLANGUAGES; BEGIN DBMSOUTPUT.PUTLINE('LANGUAGE' '-' 'TERRITORY'); DBMSOUTPUT.PUTLINE('-'); FOR rlanguages IN clanguages LOOP DBMSOUTPUT.PUTLINE(rlanguages.ISOLANGUAGE '-' rlanguages.NLSTERRITORY); END LOOP; END testwrapproc; Then go to the command prompt and run the Wrap Utility as shown below. It will create an encrypted file (testwrapproc.plb) as shown below. CREATE OR REPLACE PROCEDURE testwrapproc wrapped a000000 b2 abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd 7 181 10b 4hl/uWH5YOAzmM6zJquzeGEGdNAwgxBpDJ5qyi/Ng15TAwLsmVNle72sUpHD8uqHGgdkod4n bybKy04ihhNaEd1v4UGoQ5LKpPZ+AOi2hmiO8lpow2RqcdJ09MTiums2HFlIKrmPAM7Dgi X9J+bvS47l5LJL7g70fRIUdKDOVUwFZCEcQjH4/FvKIII70+Q5KKQAbo3DKbcjp96KfWRXbR duBC2zCLGfpAIrv5xkG4tK/fiKxVipS6CobsPUOy3ioBPA / To run and view the results of this encrypted file, go to SQL.Plus and compile the procedure. Oracle has given few Guidelines for Wrapping as below:. Wrap only the body of a package or object type, not the specification.
![]()
This allows other developers to see the information they must use the package or type, but prevents them from seeing its implementation. Wrap code only after you have finished editing it.
You cannot edit PL/SQL source code inside wrapped files. Either wrap your code after it is ready to ship to users or include the wrapping operation as part of your build environment. To change wrapped PL/SQL code, edit the original source file and then wrap it again.
Before distributing a wrapped file, view it in a text editor to be sure that all important parts are wrapped. There are few Limitations also:. Wrapping is not a secure method for hiding passwords or table names. Wrapping does not hide the source code for triggers.
To hide the workings of a trigger, write a one-line trigger that invokes a wrapped subprogram. Wrapping does not detect syntax or semantic errors. Wrapped PL/SQL units are upward-compatible between Oracle Database releases, but are not downward-compatible. For example, you can load files processed by the V8.1.5 wrap utility into a V8.1.6 Oracle Database, but you cannot load files processed by the V8.1.6 wrap utility into a V8.1.5 Oracle Database. Using DBMSDDL for Obfuscation: In prior releases you have been able to use the wrap utility to obfuscate code.
However any program unit created dynamically by using EXECUTE IMMEDIATE or DBMSSQL is not automatically wrapped. This need has been satisfied in the Oracle10gR2. The DBMSDDL package contains the WRAP and CREATEWRAPPED methods for obfuscating a single PL/SQL unit that can only be a package specification, package body, function, procedure, type specification, or type body. The wrap functions provide a mechanism for obfuscating dynamically generated PL/SQL program units that are created in a database. Benefits of Dynamic Obfuscation: Added security to dynamically generated code.
Overview of Wrapping Wrapping is the process of hiding PL/SQL source code. Wrapping helps to protect your source code from business competitors and others who might misuse it.
You can wrap PL/SQL source code with either the wrap utility or DBMSDDL subprograms. The wrap utility wraps a single source file, such as a SQL.Plus script. The DBMSDDL subprograms wrap a single dynamically generated PL/SQL unit, such as a single CREATE PROCEDURE statement.
Wrapped source files can be moved, backed up, and processed by SQL.Plus and the Import and Export utilities, but they are not visible through the static data dictionary views.SOURCE. Guidelines for Wrapping. Wrap only the body of a package or object type, not the specification. This allows other developers to see the information they must use the package or type, but prevents them from seeing its implementation. Wrap code only after you have finished editing it. You cannot edit PL/SQL source code inside wrapped files. Either wrap your code after it is ready to ship to users or include the wrapping operation as part of your build environment.
To change wrapped PL/SQL code, edit the original source file and then wrap it again. Before distributing a wrapped file, view it in a text editor to be sure that all important parts are wrapped. Limitations of Wrapping.
Wrapping is not a secure method for hiding passwords or table names. Wrapping a PL/SQL unit prevents most users from examining the source code, but might not stop all of them. Wrapping does not hide the source code for triggers. To hide the workings of a trigger, write a one-line trigger that invokes a wrapped subprogram.
Wrapping does not detect syntax or semantic errors. Wrapping detects only tokenization errors (for example, runaway strings), not syntax or semantic errors (for example, nonexistent tables or views). Syntax or semantic errors are detected during PL/SQL compilation or when executing the output file in SQL.Plus. Wrapped PL/SQL units are not downward-compatible. Wrapped PL/SQL units are upward-compatible between Oracle Database releases, but are not downward-compatible.
For example, you can load files processed by the V8.1.5 wrap utility into a V8.1.6 Oracle Database, but you cannot load files processed by the V8.1.6 wrap utility into a V8.1.5 Oracle Database. Wrapping PL/SQL Code with wrap Utility The wrap utility processes an input SQL file and wraps only the PL/SQL units in the file, such as a package specification, package body, function, procedure, type specification, or type body.
It does not wrap PL/SQL content in anonymous blocks or triggers or non-PL/SQL code. To run the wrap utility, enter the wrap command at your operating system prompt using the following syntax (with no spaces around the equal signs): wrap iname= inputfile oname= outputfile inputfile is the name of a file containing SQL statements, that you typically run using SQL.Plus. If you omit the file extension, an extension of.
Sql is assumed. For example, the following commands are equivalent: wrap iname=/mydir/myfile wrap iname=/mydir/myfile.sql You can also specify a different file extension: wrap iname=/mydir/myfile.src outputfile is the name of the wrapped file that is created. The defaults to that of the input file and its extension default is.
For example, the following commands are equivalent: wrap iname=/mydir/myfile wrap iname=/mydir/myfile.sql oname=/mydir/myfile.plb You can use the option oname to specify a different file name and extension: wrap iname=/mydir/myfile oname=/yourdir/yourfile.out. Input and Output Files for the PL/SQL wrap Utility The input file can contain any combination of SQL statements. Most statements are passed through unchanged. CREATE statements that define subprograms, packages, or object types are wrapped; their bodies are replaced by a scrambled form that the PL/SQL compiler understands. The following CREATE statements are wrapped: CREATE OR REPLACE FUNCTION functionname CREATE OR REPLACE PROCEDURE procedurename CREATE OR REPLACE PACKAGE packagename CREATE OR REPLACE PACKAGE BODY packagename CREATE OR REPLACE TYPE typename AS OBJECT CREATE OR REPLACE TYPE typename UNDER typename CREATE OR REPLACE TYPE BODY typename The CREATE OR REPLACE TRIGGER statement, and DECLARE BEGIN-END anonymous blocks, are not wrapped. All other SQL statements are passed unchanged to the output file. All comment lines in the unit being wrapped are deleted, except for those in a CREATE OR REPLACE header and C-style comments (delimited by /./).
The output file is a text file, which you can run as a script in SQL.Plus to set up your PL/SQL subprograms and packages. Run a wrapped file as follows: SQL @wrappedfilename.plb. Wrapping PL/QL Code with DBMSDDL Subprograms The DBMSDDL package contains procedures for wrapping a single PL/SQL unit, such as a package specification, package body, function, procedure, type specification, or type body. These overloaded subprograms provide a mechanism for wrapping dynamically generated PL/SQL units that are created in a database.
The DBMSDDL package contains the WRAP functions and the CREATEWRAPPED procedures. The CREATEWRAPPED both wraps the text and creates the PL/SQL unit. When invoking the wrap procedures, use the fully qualified package name, SYS.DBMSDDL, to avoid any naming conflicts and the possibility that someone might create a local package called DBMSDDL or define the DBMSDDL public synonym.
The input CREATE OR REPLACE statement executes with the privileges of the user who invokes DBMSDDL. WRAP or DBMSDDL. The DBMSDDL package also provides the MALFORMEDWRAPINPUT exception (ORA-24230) which is raised if the input to the wrap procedures is not a valid PL/SQL unit.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |