I have Erlang application's beam files which I want to decompile.
Application is Compiled and build with 'debug_info' options. here is snippet of emake file to which is used to build application :
{"apps/my_app/src/*", [debug_info, nowarn_export_all, {outdir, "apps/my_app/ebin"},{pa, "deps"},{parse_transform, lager_transform}, {parse_transform, events_transform}]}.
I have tried function from beam_lib module but getting following Error :
1>{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(abc,[abstract_code]).
** exception error: no match of right hand side value {error,beam_lib,{not_a_beam_file,'abc.beam'}}
I have also tried solution mentioned in following post Decompile erlang .beam files compiled without debug_info but Its not working for me. I'm getting following error :
1> file:write_file("/tmp/my_module_disasm", io_lib:fwrite("~p.\n", [beam_disasm:file(abc)])).
ok
/tmp/my_module_disasm file contains :
{error,beam_lib,{not_a_beam_file,'abc.beam'}}.
Anyone have Idea ?
abc) is not compiled. What doescode:which(abc).return? – Brujo Benavides Nov 01 '17 at 21:10FOR1____BEAM(i.e. something that matches<<"FOR1", _Size:32, "BEAM">>.Out of curiosity, can you show me the first 12 bytes of your abc.beam file?
– Brujo Benavides Nov 02 '17 at 12:48FOR1is actually just a Magic number indicating an IFF form. This is an extension to IFF indicating that all chunks are four-byte aligned. and it's used to build and scan all .beam files since at least R13B03 (i.e. a long time ago). So, two more questions:- What does
- Any way you can share your beam file with us?
– Brujo Benavides Nov 02 '17 at 18:00abc:module_info().return?abc:module_info().[{module,abc}, {exports,[...]}, {attributes,[{vsn,[10...]}, {declared_records,[]}]}, {compile,[{options,[{parse_transform,events_transform}, compressed, {source,"apps/***/src/abc.erl"}, {i,"apps/***/include"}, nowarn_export_all, {d,production}]}, {version,"2.0"}, {source,".../src/abc.erl"}]}, {native,false}, {md5,<<75,214,244,246,35,73,154,180,70,208,143,93,40, 254,32,143>>}]– parmar7725274 Nov 03 '17 at 04:14optionsreported byabc:module_info().(i.e.[{parse_transform,events_transform}, compressed, {source,"apps/***/src/abc.erl"}, {i,"apps/***/include"}, nowarn_export_all, {d,production}]), it looks like the module is not compiled withdebug_info. But, if that would be the case, the reported error should beno_abstract_code. – Brujo Benavides Nov 03 '17 at 11:41https://gist.github.com/elbrujohalcon/bc93e6a6881b3395da2318f567b4638d
Is this not happening on your computer?
– Brujo Benavides Nov 10 '17 at 12:05