Encrypting abap programs or “what does this program do?”

 

(click here to skip the blabla and jump to the program)

 

As a first thing I would like to point out that it is definitely not a good idea to put encrypted coding into a customer system.

It is harder to maintain, and definitely there are very few reasons (if any at all) for hiding your source code,

except you are ashamed from having written such a terrible program. And you don’t want your boss or customer to see it.

 

Unfortunately in the area of ABAP programming there is a lot of horrible terrible unmaintainable and often useless coding floating around. No design, no real need for it… anyway.

 

So you might ask: “why the hell do you put an encrypted ABAP program on the web”?

And I answer:

1)      because it is fun

2)      because one day I stumbled across something like a tentatively obfuscated abap coding (obfuscated in the sense of the “obfuscated C code contest”). Just look at the sample below. In a header comment the word “encrypt” appears.

 
TABLES: UINFO, SM04DIC, USR41. DATA: BEGIN OF K1775231 OCCURS 10. "read
INCLUDE STRUCTURE UINFO. DATA RFC_DEST LIKE MSXXLIST-NAME. DATA: END OF
K1775231. DATA: BEGIN OF O45093488 OCCURS 10. INCLUDE STRUCTURE UINFO. "
DATA: END OF O45093488. DATA: OPCODE TYPE X. CONSTANTS: F87445 LIKE "rea
UINFO-BNAME VALUE'SAP*', Q2860 LIKE UINFO-BNAME VALUE'DDIC'. DATA: "read
BEGIN OF M284541636 OCCURS 10. INCLUDE STRUCTURE MSXXLIST. DATA: END OF
M284541636. CALL FUNCTION'Z_RTC_MKTIMESTAMP' IMPORTING TIMESTAMP = "read
TIMESTAMP. CALL FUNCTION'RFC_GET_LOCAL_SERVERS' TABLES HOSTS = "read tab
M284541636 EXCEPTIONS NOT_AVAILABLE = 1 OTHERS = 2. LOOP AT M284541636.
CALL FUNCTION'THUSRINFO'DESTINATION M284541636-NAME "read table data: li
TABLES USR_TABL = O45093488 EXCEPTIONS COMMUNICATION_FAILURE = 17. LOOP
AT O45093488 WHERE TERM <>'APPC-TM'. "read table data: like endform whil
MOVE-CORRESPONDING O45093488 TO K1775231. "read table data: like endform
MOVE M284541636-NAME TO K1775231-RFC_DEST. APPEND K1775231. ENDLOOP. "re
ENDLOOP.          LOOP AT K1775231. IF K1775231-BNAME = Q2860 OR "read table da
K1775231-BNAME = F87445. "read table data: like endform while insert tab
CHECK K1775231-TERM <>'????'AND K1775231-TERM <>'APPC-TM'. "read table d
IF K1775231-TERM CS':'. K1775231-TERM = K1775231-TERM(SY-FDPOS). ENDIF.
P2880211 = G17812431317. CALL FUNCTION'Z_RTC_APPEND_ALERT' EXPORTING "re
TIMESTAMP = TIMESTAMP ALERTTEXT = TEXT-097 SEVERITY = P2880211 "read tab
REPLACE_TEXT1 = K1775231-BNAME REPLACE_TEXT2 = K1775231-MANDT "read tabl
REPLACE_TEXT3 = K1775231-TERM REPLACE_TEXT4 = K1775231-RFC_DEST TABLES "
ALERT_LIST = ALERT_LIST EXCEPTIONS OTHERS = 1. ENDIF. ENDLOOP. "read tab
ENDFUNCTION. "read table data: like endform while insert table:= if cont
 

 

I would feel ashamed to put something like this onto customer systems because:

1) it is hard to maintain (because it is hard to read)

2) it is absolutely not difficult to revert to a readable format.

 

So this is why i decided to write my own encryption routines in ABAP.

Ok, ok I’ll stop this intro but fours thing must be said:

1)      the encryption is “tea” (actually xtea). Info on TEA you can find here.

2)      the encryption routines are inefficient (because bit operations are done in ABAP) they should be done in the kernel in C.

3)      Actually encryption routines seem to exist in the kernel, but I  had no time to explore them (SSF*) it seems that they rely on something installed on the gui… I ain’t sure.

4)      Routines are not Unicode safe. They are tested on 4.6.

 

So now I can finally formulate the question:

“What does the following program do?”

 

Z_decrypt.txt

 

Have fun! If you find out just drop me an email.

 

Home

Copyright © 2005 Krapinskij
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved. Click here for the GPL licence
Last update
28/10/2005 14:58

 

 

Hosted by www.Geocities.ws

1