Firebird, decrypt stored procedure?

偶尔善良 提交于 2019-12-23 20:24:45

问题


I got myself into a place where I need to port some functionality from a legacy Firebird database into MSSQL. The table schema and data was ok, all was enumerable and selectable for sysdba, however, the application layer is proving to be a pain. The database has some 1000+ procedures and I would like to to move them over with some review rather than rebuilding the whole DAL. The problem is (you guessed) that they all appear to be encrypted somehow. When I ask to alter it to generate a script I get the ALTER script but the body of the procedure looks like a base64 string of some binary content. My first guess is encryption.

Is there some way to decrypt those bodies, like there is for MSSQL? Please note that Firebird database is running on its original box, in its original Firebird installation, nothing has been copied or moved, in case access to some keys is required.


回答1:


When you create (or alter) a stored procedure in Firebird, Firebird will store the original body in column RDB$PROCEDURE_SOURCE of table RDB$PROCEDURES. This will not be encrypted. This body is not relevant for Firebird itself, as it will use the compiled form of the stored procedure (in column RDB$PROCEDURE_BLR); it is only stored to allow isql (and other tools) to generate the DDL script of the database.

Some software vendors don't like that people have access to their sourcecode, and so they will either null this RDB$PROCEDURE_SOURCE column or - as is likely the case with your database - encrypt the body in some way.

If this is an application that was developed in-house, you will need to find the original scripts used to build this database.

Otherwise there is no way to undo this without knowing exactly what the vendor (or developer) has done. Another possible solution would be to reverse engineer to stored procedure from the BLR (Binary Language Representation, the compiled form of the stored procedure), but I am not aware of tools that do this (and this might not result in very readable code).

Doing either of these might violate the license agreement, and maybe even local law. Your best bet would be to contact the vendor of this legacy application and ask (or pay) them for this source code.

The ISQL tool can print the BLR in 'readable' form, but as it is very low-level, I don't know how helpful that will be. For an example see this answer.




回答2:


Since Firebird 3.0, database encryption is now possible ...so it has nothing to do with the Firebird installation, rather the database it self was already encrypted, I'm afraid you'll need the encryption keys to decrypt the data read these articles:

http://firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-security-encryption.html

http://tracker.firebirdsql.org/browse/CORE-657



来源:https://stackoverflow.com/questions/37189400/firebird-decrypt-stored-procedure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!