erlang防止反编译

前面提到了erlang的反编译,下面说下防止反编译:

1)建立~/.erlang.crypt

在编译的用户名的home目录中建立一个加密方法的文件.erlang.crypt,内容如下:

[{debug_info, des3_cbc, [], "secret_key"}].

%使用des3_cbc的算法来对文件进行加密,加密的密钥为secret_key。

2)修改Emakefile

修改Emakefile的内容为:

{ ["src/*", "src/**/*","src/***/**/*"]

        , [encrypt_debug_info,

                {i, "include"},

                {outdir, "./ebin"}]

}.

%使用.erlang.crypt方法对源代码进行编译,并输出到ebin目录。

3)编译源代码

进入sh目录,运行./make.sh对源代码进行编译。

4)移除.erlang.crypt文件

我们移除~/.erlang.crypt,然后在测试是否可以反编译,以下是测试的过程:

[root@root1 ebin]# mv ~/.erlang.crypt ~/.erlang.old.crypt

[root@root1 ebin]# erl

Eshell V5.8.1  (abort with ^G)

1> beam_lib:chunks(code:which(abc), [abstract_code]).

{error,beam_lib,

       {key_missing_or_invalid,"./abc.beam",abstract_code}}

 

当我们移除~/.erlang.crypt之后再进行反编译,得到找不到加密串的结果,这样对方就无法对我们的编译好的文件进行反编译。

 

posted @ 2014-05-19 18:43  孤独信徒  阅读(1463)  评论(0编辑  收藏  举报