Dear my readers here i put how to unwrap a pl/sql wrapped code
SQL> get sample1.sql
  1  create or replace procedure test_proc (pv_num
in number,
  2     pv_var in varchar2, pv_var3 in out
integer)  is
  3     l_num number:=3;
  4     l_var number;
  5     j number:=1;
  6     procedure nested (pv_len in out number)
  7     is
  8       
     x number;
  9     begin
 10            
x:=pv_len*5;
 11     end;
 12  begin
 13     case l_num
 14            
when 1 then
 15                     -- IF 1
 16                     l_var:=3;
 17                     dbms_output.put_line('This is a header');
 18                     dbms_output.put_line('The number is '||l_var);
 19                     dbms_output.put_line('The case var is '||l_num);
 20            
when 2 then
 21                     -- IF 2
 22                     l_var:=4;
 23         
           dbms_output.put_line('This is a header');
 24                     dbms_output.put_line('The number is '||l_var);
 25                     dbms_output.put_line('The case var is '||l_num);
 26            
when 3 then
 27                     -- IF 3
 28                     l_var:=6;
 29                     dbms_output.put_line('This is a header');
 30                     dbms_output.put_line('The number is '||l_var);
 31                     dbms_output.put_line('The case var is '||l_num);
 32            
else
 33                     dbms_output.put_line('wrong choice');
 34     end case;
 35     if ((j=1) and (j=3)) then
 36            
dbms_output.put_line('here
is IF');
 37     elsif ((j=2) or (j!=3)) then
 38            
dbms_output.put_line('The
elsif clause');
 39     else
 40            
dbms_output.put_line('else
clause');
 41     end if;
 42     j:=4;
 43     nested(j);
 44     dbms_output.put_line('nested=:'||j);
 45     for j in reverse 1..pv_num
 46     loop
 47            
if mod(j,2) = 0 then
 48                     dbms_output.put_line('for loop with reverse');
 49            
end if;
 50     end loop;
 51* end;
SQL>
I can then wrap this with the 9i
wrap utility:
C:\unwrapper>wrap
iname=sample1.sql oname=sample1.plb
PL/SQL Wrapper: Release 9.2.0.1.0-
Production on Mon Jun 01 14:02:34 2009
Copyright (c) Oracle Corporation
1993, 2001.  All Rights Reserved.
Processing sample1.sql to
sample1.plb
C:\unwrapper>head sample1.plb
Then I can show it is indeed
wrapped by viewing the contents (Note the above commands are in a DOS box, the
head command is on the same machine but from cygwin as the head command is
available:
$
head -20 sample1.plb
create or replace procedure
test_proc wrapped
0
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
3
7
9200000
Now load the wrapped file into an
11gR1 database and check its stored wrapped:
SQL> @sample1.plb
Procedure created.
SQL> select substr(text,1,60)
  2  from dba_source
  3  where name='TEST_PROC'
  4  and rownum=1;
SUBSTR(TEXT,1,60)
------------------------------------------------------------
procedure test_proc wrapped
0
abcd
abcd
abcd
abcd
abcd
abcd
SQL>
Now we can simply unwrap it using
my PL/SQL based unwrapper:
SQL> @unwrap_c
unwrap_c: Release 1.4.0.0.0 -
Production on Mon Jun 01 14:07:13 2009
Copyright (c) 2008, 2009
PeteFinnigan.com Limited. All rights reserved.
NAME OF OBJECT TO CHECK                 [P1]: TEST_PROC
OWNER OF OBJECT TO CHECK               [SYS]: SYS
TYPE OF THE OBJECT               [PROCEDURE]: PROCEDURE
OUTPUT METHOD Screen/File                [S]: S
FILE NAME FOR OUTPUT              [priv.lst]:
OUTPUT DIRECTORY [DIRECTORY  or file (/tmp)]:
create or replace procedure
TEST_PROC( PV_NUM in NUMBER,
 PV_VAR
in VARCHAR2, PV_VAR3 in out INTEGER) is
 L_NUM
NUMBER:=3;
 L_VAR
NUMBER;
 J
NUMBER:=1;
procedure NESTED( PV_LEN in out
NUMBER) is
 X
NUMBER;
begin
 X:=
PV_LEN * 5;
end;
begin
case L_NUM
 when
1 then
 L_VAR:=3;
 DBMS_OUTPUT.
PUT_LINE('This is a header');
 DBMS_OUTPUT.
PUT_LINE('The number is ' ||  L_VAR);
 DBMS_OUTPUT.
PUT_LINE('The case var is ' ||  L_NUM);
 when
2 then
 L_VAR:=4;
 DBMS_OUTPUT.
PUT_LINE('This is a header');
 DBMS_OUTPUT.
PUT_LINE('The number is ' ||  L_VAR);
 DBMS_OUTPUT.
PUT_LINE('The case var is ' ||  L_NUM);
 when
3 then
 L_VAR:=6;
 DBMS_OUTPUT.
PUT_LINE('This is a header');
 DBMS_OUTPUT.
PUT_LINE('The number is ' ||  L_VAR);
 DBMS_OUTPUT.
PUT_LINE('The case var is ' ||  L_NUM);
else
 DBMS_OUTPUT.
PUT_LINE('wrong choice');
end case;
if ( ( J = 1) and ( J = 3)) then
 DBMS_OUTPUT.
PUT_LINE('here is IF');
elsif ( ( J = 2) or ( J != 3))
then
 DBMS_OUTPUT.
PUT_LINE('The elsif clause');
else
 DBMS_OUTPUT.
PUT_LINE('else clause');
end if;
 J:=4;
 NESTED(
J);
 DBMS_OUTPUT.
PUT_LINE('nested=:' ||  J);
for J in reverse 1.. PV_NUM loop
if MOD( J,2) = 0 then
 DBMS_OUTPUT.
PUT_LINE('for loop with reverse');
end if;
end loop;
end;
/
INFO: Elapsed time = [.1 Seconds]
PL/SQL procedure successfully
completed.
No comments:
Post a Comment