erlang beam文件反编译
来源:互联网 发布:党章党规网络测试题 编辑:程序博客网 时间:2024/06/05 18:27
hello~ ,
如果erlang源码被意外删除只留下编译后的beam文件的时候怎么办?如果源码能还原也就大事化了, 如果不能就懵了?都有手误的是时候,今天就来聊聊erlang的反编译,到时也不至于乱了手脚。
在仔细翻阅文档之后终于找到了erlang反编译相关的说明,地址:http://erlang.org/doc/man/beam_lib.html 。beam_lib 模块就是对deam文件格式的接口。
其中最主要的是这两行代码:
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]).io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
so ~ 废话少说,直接上代码。
源码:
-module(test).-export([hello/0,say/0]).hello() ->"hello ~".%%@doc say hello~say() ->lists:foreach(fun hello/0 , lists:seq(1, 10)).
先看下面
在chunks之后并没有成功,提示是no_abstract_code,这是为什么呢?查看文档,在文档中找到如下说明:
Option debug_info can be specified to the Compiler (see compile(3)) to have debug information in the form of abstract code (see section The Abstract Format in the ERTS User's Guide) stored in the abstract_code chunk. Tools such as Debugger and Xref require the debug information to be included.
大致的意思是:要想反编译就必须在编译的时候加上+debug_info标记,现在我们再来试试:
这次成功了~
不过欢喜之余我们马上会发现,自己能反编译成功那别人也肯定能, 这样就存在安全问题了,那么有没有办法解决这个问题呢?幸运的是文档里给出了解决方法。有两种方法:
The key can be provided in the following two ways:
Use Compiler option {debug_info,Key}, see compile(3) and function crypto_key_fun/1 to register a fun that returns the key whenever beam_lib must decrypt the debug information.
If no such fun is registered, beam_lib instead searches for an .erlang.crypt file, see the next section.
Store the key in a text file named .erlang.crypt.
In this case, Compiler option encrypt_debug_info can be used, see compile(3).
我这里是[{debug_info, des3_cbc, [], "my_key"}].
再来看
也成功了, 注意这里要加encrypt_debug_info而不是debug_info,
现在我们来修改.erlang.crypt文件里的内容为[{debug_info, des3_cbc, [], "no_key"}]. 或者删除.erlang.crypt文件再来尝试:
失败了,意思是说加密验证不通过。
现在没什么好担心的啦~放心去干吧!!
祝生活愉快!
- erlang beam文件反编译
- [Erlang]如何防止beam文件的反编译
- erlang反编译
- erlang 反编译
- Basic Types in Erlang Beam Emulator
- erlang 防止反编译
- erlang 代码反编译
- Apache Beam访问HDFS文件
- [Erlang]配置文件读取方式(ETS,BEAM)性能研究
- Erlang 虚拟机 BEAM 指令集之内存管理相关的指令
- Erlang项目编译及防止反编译
- Erlang代码反编译以及查看汇编码
- Python反编译&pyc文件反编译
- Erlang的EmakeFile文件
- erlang文件操作
- cowboy erlang 文件上传
- cowboy erlang 上传文件
- erlang .app文件主要参数
- 开发笔记 - UITableView相关
- Python Web 开发学习 - 学习笔记(2)- 启动Python
- API性能测试基本性能指标及要求
- 第一站-部署开发工具
- hadoop1.2.1的安装
- erlang beam文件反编译
- 转载的开源干货
- Java基础--数组
- Windows环境下使用python selenium 打开Firefox的问题总结
- 枚举的用法
- 关于SAP的号码范围(number range)
- 关于“因为数据库正在使用,所以无法获得对数据库的独占访问权”的最终解决方案
- 强大的jquery上传插件SWF版Uploadify参数详解
- 浅谈开博